outgoing.c (253895) | outgoing.c (262324) |
---|---|
1/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * --- 67 unchanged lines hidden (view full) --- 76 77 serf__log(CONN_VERBOSE, __FILE__, "cleaning up connection 0x%x\n", 78 conn); 79 serf_connection_close(conn); 80 81 return APR_SUCCESS; 82} 83 | 1/* Copyright 2002-2004 Justin Erenkrantz and Greg Stein 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * --- 67 unchanged lines hidden (view full) --- 76 77 serf__log(CONN_VERBOSE, __FILE__, "cleaning up connection 0x%x\n", 78 conn); 79 serf_connection_close(conn); 80 81 return APR_SUCCESS; 82} 83 |
84/* Check if there is data waiting to be sent over the socket. This can happen 85 in two situations: 86 - The connection queue has atleast one request with unwritten data. 87 - All requests are written and the ssl layer wrote some data while reading 88 the response. This can happen when the server triggers a renegotiation, 89 e.g. after the first and only request on that connection was received. 90 Returns 1 if data is pending on CONN, NULL if not. 91 If NEXT_REQ is not NULL, it will be filled in with the next available request 92 with unwritten data. */ 93static int 94request_or_data_pending(serf_request_t **next_req, serf_connection_t *conn) 95{ 96 serf_request_t *request = conn->requests; 97 98 while (request != NULL && request->req_bkt == NULL && 99 request->writing_started) 100 request = request->next; 101 102 if (next_req) 103 *next_req = request; 104 105 if (request != NULL) { 106 return 1; 107 } else if (conn->ostream_head) { 108 const char *dummy; 109 apr_size_t len; 110 apr_status_t status; 111 112 status = serf_bucket_peek(conn->ostream_head, &dummy, 113 &len); 114 if (!SERF_BUCKET_READ_ERROR(status) && len) { 115 serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt, 116 "All requests written but still data pending.\n"); 117 return 1; 118 } 119 } 120 121 return 0; 122} 123 |
|
84/* Update the pollset for this connection. We tweak the pollset based on 85 * whether we want to read and/or write, given conditions within the 86 * connection. If the connection is not (yet) in the pollset, then it 87 * will be added. 88 */ 89apr_status_t serf__conn_update_pollset(serf_connection_t *conn) 90{ 91 serf_context_t *ctx = conn->ctx; --- 29 unchanged lines hidden (view full) --- 121 * has unwritten data or 122 * there are any requests that still have buckets to write out, 123 * then we want to write. 124 */ 125 if (conn->vec_len && 126 conn->state != SERF_CONN_CLOSING) 127 desc.reqevents |= APR_POLLOUT; 128 else { | 124/* Update the pollset for this connection. We tweak the pollset based on 125 * whether we want to read and/or write, given conditions within the 126 * connection. If the connection is not (yet) in the pollset, then it 127 * will be added. 128 */ 129apr_status_t serf__conn_update_pollset(serf_connection_t *conn) 130{ 131 serf_context_t *ctx = conn->ctx; --- 29 unchanged lines hidden (view full) --- 161 * has unwritten data or 162 * there are any requests that still have buckets to write out, 163 * then we want to write. 164 */ 165 if (conn->vec_len && 166 conn->state != SERF_CONN_CLOSING) 167 desc.reqevents |= APR_POLLOUT; 168 else { |
129 serf_request_t *request = conn->requests; | |
130 131 if ((conn->probable_keepalive_limit && 132 conn->completed_requests > conn->probable_keepalive_limit) || 133 (conn->max_outstanding_requests && 134 conn->completed_requests - conn->completed_responses >= 135 conn->max_outstanding_requests)) { 136 /* we wouldn't try to write any way right now. */ | 169 170 if ((conn->probable_keepalive_limit && 171 conn->completed_requests > conn->probable_keepalive_limit) || 172 (conn->max_outstanding_requests && 173 conn->completed_requests - conn->completed_responses >= 174 conn->max_outstanding_requests)) { 175 /* we wouldn't try to write any way right now. */ |
137 } 138 else { 139 while (request != NULL && request->req_bkt == NULL && 140 request->written) 141 request = request->next; 142 if (request != NULL) 143 desc.reqevents |= APR_POLLOUT; | |
144 } | 176 } |
177 else if (request_or_data_pending(NULL, conn)) { 178 desc.reqevents |= APR_POLLOUT; 179 } |
|
145 } 146 } 147 } 148 149 /* If we can have async responses, always look for something to read. */ 150 if (conn->async_responses) { 151 desc.reqevents |= APR_POLLIN; 152 } --- 235 unchanged lines hidden (view full) --- 388 return status; 389 } 390 } 391 } 392 393 return APR_SUCCESS; 394} 395 | 180 } 181 } 182 } 183 184 /* If we can have async responses, always look for something to read. */ 185 if (conn->async_responses) { 186 desc.reqevents |= APR_POLLIN; 187 } --- 235 unchanged lines hidden (view full) --- 423 return status; 424 } 425 } 426 } 427 428 return APR_SUCCESS; 429} 430 |
396static apr_status_t no_more_writes(serf_connection_t *conn, 397 serf_request_t *request) | 431static apr_status_t no_more_writes(serf_connection_t *conn) |
398{ 399 /* Note that we should hold new requests until we open our new socket. */ 400 conn->state = SERF_CONN_CLOSING; | 432{ 433 /* Note that we should hold new requests until we open our new socket. */ 434 conn->state = SERF_CONN_CLOSING; |
401 serf__log(CONN_VERBOSE, __FILE__, "stop writing on conn 0x%x\n", 402 conn); | 435 serf__log_skt(CONN_VERBOSE, __FILE__, conn->skt, 436 "stop writing on conn 0x%x\n", conn); |
403 404 /* Clear our iovec. */ 405 conn->vec_len = 0; 406 407 /* Update the pollset to know we don't want to write on this socket any 408 * more. 409 */ 410 conn->dirty_conn = 1; --- 128 unchanged lines hidden (view full) --- 539 conn->requests = NULL; 540 conn->requests_tail = NULL; 541 542 /* Handle all outstanding requests. These have either not been written yet, 543 or have been written but the expected reply wasn't received yet. */ 544 while (old_reqs) { 545 /* If we haven't started to write the connection, bring it over 546 * unchanged to our new socket. | 437 438 /* Clear our iovec. */ 439 conn->vec_len = 0; 440 441 /* Update the pollset to know we don't want to write on this socket any 442 * more. 443 */ 444 conn->dirty_conn = 1; --- 128 unchanged lines hidden (view full) --- 573 conn->requests = NULL; 574 conn->requests_tail = NULL; 575 576 /* Handle all outstanding requests. These have either not been written yet, 577 or have been written but the expected reply wasn't received yet. */ 578 while (old_reqs) { 579 /* If we haven't started to write the connection, bring it over 580 * unchanged to our new socket. |
581 * Do not copy a CONNECT request to the new connection, the ssl tunnel 582 * setup code will create a new CONNECT request already. |
|
547 */ | 583 */ |
548 if (requeue_requests && !old_reqs->written) { | 584 if (requeue_requests && !old_reqs->writing_started && 585 !old_reqs->ssltunnel) { 586 |
549 serf_request_t *req = old_reqs; 550 old_reqs = old_reqs->next; 551 req->next = NULL; 552 link_requests(&conn->requests, &conn->requests_tail, req); 553 } 554 else { 555 /* Request has been consumed, or we don't want to requeue the 556 request. Either way, inform the application that the request --- 110 unchanged lines hidden (view full) --- 667 &request->handler_baton, 668 request->respool); 669 return status; 670} 671 672/* write data out to the connection */ 673static apr_status_t write_to_connection(serf_connection_t *conn) 674{ | 587 serf_request_t *req = old_reqs; 588 old_reqs = old_reqs->next; 589 req->next = NULL; 590 link_requests(&conn->requests, &conn->requests_tail, req); 591 } 592 else { 593 /* Request has been consumed, or we don't want to requeue the 594 request. Either way, inform the application that the request --- 110 unchanged lines hidden (view full) --- 705 &request->handler_baton, 706 request->respool); 707 return status; 708} 709 710/* write data out to the connection */ 711static apr_status_t write_to_connection(serf_connection_t *conn) 712{ |
675 serf_request_t *request = conn->requests; 676 | |
677 if (conn->probable_keepalive_limit && 678 conn->completed_requests > conn->probable_keepalive_limit) { 679 680 conn->dirty_conn = 1; 681 conn->ctx->dirty_pollset = 1; 682 683 /* backoff for now. */ 684 return APR_SUCCESS; 685 } 686 | 713 if (conn->probable_keepalive_limit && 714 conn->completed_requests > conn->probable_keepalive_limit) { 715 716 conn->dirty_conn = 1; 717 conn->ctx->dirty_pollset = 1; 718 719 /* backoff for now. */ 720 return APR_SUCCESS; 721 } 722 |
687 /* Find a request that has data which needs to be delivered. */ 688 while (request != NULL && 689 request->req_bkt == NULL && request->written) 690 request = request->next; 691 692 /* assert: request != NULL || conn->vec_len */ 693 | |
694 /* Keep reading and sending until we run out of stuff to read, or 695 * writing would block. 696 */ 697 while (1) { | 723 /* Keep reading and sending until we run out of stuff to read, or 724 * writing would block. 725 */ 726 while (1) { |
727 serf_request_t *request; |
|
698 int stop_reading = 0; 699 apr_status_t status; 700 apr_status_t read_status; | 728 int stop_reading = 0; 729 apr_status_t status; 730 apr_status_t read_status; |
701 serf_bucket_t *ostreamt, *ostreamh; | 731 serf_bucket_t *ostreamt; 732 serf_bucket_t *ostreamh; |
702 int max_outstanding_requests = conn->max_outstanding_requests; 703 704 /* If we're setting up an ssl tunnel, we can't send real requests 705 at yet, as they need to be encrypted and our encrypt buckets 706 aren't created yet as we still need to read the unencrypted 707 response of the CONNECT request. */ 708 if (conn->state != SERF_CONN_CONNECTED) 709 max_outstanding_requests = 1; --- 12 unchanged lines hidden (view full) --- 722 /* If the write would have blocked, then we're done. Don't try 723 * to write anything else to the socket. 724 */ 725 if (APR_STATUS_IS_EAGAIN(status)) 726 return APR_SUCCESS; 727 if (APR_STATUS_IS_EPIPE(status) || 728 APR_STATUS_IS_ECONNRESET(status) || 729 APR_STATUS_IS_ECONNABORTED(status)) | 733 int max_outstanding_requests = conn->max_outstanding_requests; 734 735 /* If we're setting up an ssl tunnel, we can't send real requests 736 at yet, as they need to be encrypted and our encrypt buckets 737 aren't created yet as we still need to read the unencrypted 738 response of the CONNECT request. */ 739 if (conn->state != SERF_CONN_CONNECTED) 740 max_outstanding_requests = 1; --- 12 unchanged lines hidden (view full) --- 753 /* If the write would have blocked, then we're done. Don't try 754 * to write anything else to the socket. 755 */ 756 if (APR_STATUS_IS_EAGAIN(status)) 757 return APR_SUCCESS; 758 if (APR_STATUS_IS_EPIPE(status) || 759 APR_STATUS_IS_ECONNRESET(status) || 760 APR_STATUS_IS_ECONNABORTED(status)) |
730 return no_more_writes(conn, request); | 761 return no_more_writes(conn); |
731 if (status) 732 return status; 733 } 734 /* ### can we have a short write, yet no EAGAIN? a short write 735 ### would imply unwritten_len > 0 ... */ 736 /* assert: unwritten_len == 0. */ 737 738 /* We may need to move forward to a request which has something 739 * to write. 740 */ | 762 if (status) 763 return status; 764 } 765 /* ### can we have a short write, yet no EAGAIN? a short write 766 ### would imply unwritten_len > 0 ... */ 767 /* assert: unwritten_len == 0. */ 768 769 /* We may need to move forward to a request which has something 770 * to write. 771 */ |
741 while (request != NULL && 742 request->req_bkt == NULL && request->written) 743 request = request->next; 744 745 if (request == NULL) { | 772 if (!request_or_data_pending(&request, conn)) { |
746 /* No more requests (with data) are registered with the | 773 /* No more requests (with data) are registered with the |
747 * connection. Let's update the pollset so that we don't 748 * try to write to this socket again. | 774 * connection, and no data is pending on the outgoing stream. 775 * Let's update the pollset so that we don't try to write to this 776 * socket again. |
749 */ 750 conn->dirty_conn = 1; 751 conn->ctx->dirty_pollset = 1; 752 return APR_SUCCESS; 753 } 754 755 status = prepare_conn_streams(conn, &conn->stream, &ostreamt, &ostreamh); 756 if (status) { 757 return status; 758 } 759 | 777 */ 778 conn->dirty_conn = 1; 779 conn->ctx->dirty_pollset = 1; 780 return APR_SUCCESS; 781 } 782 783 status = prepare_conn_streams(conn, &conn->stream, &ostreamt, &ostreamh); 784 if (status) { 785 return status; 786 } 787 |
760 if (request->req_bkt == NULL) { 761 read_status = setup_request(request); 762 if (read_status) { 763 /* Something bad happened. Propagate any errors. */ 764 return read_status; | 788 if (request) { 789 if (request->req_bkt == NULL) { 790 read_status = setup_request(request); 791 if (read_status) { 792 /* Something bad happened. Propagate any errors. */ 793 return read_status; 794 } |
765 } | 795 } |
766 } | |
767 | 796 |
768 if (!request->written) { 769 request->written = 1; 770 serf_bucket_aggregate_append(ostreamt, request->req_bkt); | 797 if (!request->writing_started) { 798 request->writing_started = 1; 799 serf_bucket_aggregate_append(ostreamt, request->req_bkt); 800 } |
771 } 772 773 /* ### optimize at some point by using read_for_sendfile */ 774 /* TODO: now that read_iovec will effectively try to return as much 775 data as available, we probably don't want to read ALL_AVAIL, but 776 a lower number, like the size of one or a few TCP packets, the 777 available TCP buffer size ... */ 778 read_status = serf_bucket_read_iovec(ostreamh, --- 34 unchanged lines hidden (view full) --- 813 status = socket_writev(conn); 814 815 /* If we can't write any more, or an error occurred, then 816 * we're done here. 817 */ 818 if (APR_STATUS_IS_EAGAIN(status)) 819 return APR_SUCCESS; 820 if (APR_STATUS_IS_EPIPE(status)) | 801 } 802 803 /* ### optimize at some point by using read_for_sendfile */ 804 /* TODO: now that read_iovec will effectively try to return as much 805 data as available, we probably don't want to read ALL_AVAIL, but 806 a lower number, like the size of one or a few TCP packets, the 807 available TCP buffer size ... */ 808 read_status = serf_bucket_read_iovec(ostreamh, --- 34 unchanged lines hidden (view full) --- 843 status = socket_writev(conn); 844 845 /* If we can't write any more, or an error occurred, then 846 * we're done here. 847 */ 848 if (APR_STATUS_IS_EAGAIN(status)) 849 return APR_SUCCESS; 850 if (APR_STATUS_IS_EPIPE(status)) |
821 return no_more_writes(conn, request); | 851 return no_more_writes(conn); |
822 if (APR_STATUS_IS_ECONNRESET(status) || 823 APR_STATUS_IS_ECONNABORTED(status)) { | 852 if (APR_STATUS_IS_ECONNRESET(status) || 853 APR_STATUS_IS_ECONNABORTED(status)) { |
824 return no_more_writes(conn, request); | 854 return no_more_writes(conn); |
825 } 826 if (status) 827 return status; 828 } 829 830 if (read_status == SERF_ERROR_WAIT_CONN) { 831 stop_reading = 1; 832 conn->stop_writing = 1; 833 conn->dirty_conn = 1; 834 conn->ctx->dirty_pollset = 1; 835 } | 855 } 856 if (status) 857 return status; 858 } 859 860 if (read_status == SERF_ERROR_WAIT_CONN) { 861 stop_reading = 1; 862 conn->stop_writing = 1; 863 conn->dirty_conn = 1; 864 conn->ctx->dirty_pollset = 1; 865 } |
836 else if (read_status && conn->hit_eof && conn->vec_len == 0) { | 866 else if (request && read_status && conn->hit_eof && 867 conn->vec_len == 0) { |
837 /* If we hit the end of the request bucket and all of its data has 838 * been written, then clear it out to signify that we're done 839 * sending the request. On the next iteration through this loop: 840 * - if there are remaining bytes they will be written, and as the 841 * request bucket will be completely read it will be destroyed then. 842 * - we'll see if there are other requests that need to be sent 843 * ("pipelining"). 844 */ --- 47 unchanged lines hidden (view full) --- 892 pool); 893 894 /* If there was an error reading the response (maybe there wasn't 895 enough data available), don't bother passing the response to the 896 application. 897 898 If the authentication was tried, but failed, pass the response 899 to the application, maybe it can do better. */ | 868 /* If we hit the end of the request bucket and all of its data has 869 * been written, then clear it out to signify that we're done 870 * sending the request. On the next iteration through this loop: 871 * - if there are remaining bytes they will be written, and as the 872 * request bucket will be completely read it will be destroyed then. 873 * - we'll see if there are other requests that need to be sent 874 * ("pipelining"). 875 */ --- 47 unchanged lines hidden (view full) --- 923 pool); 924 925 /* If there was an error reading the response (maybe there wasn't 926 enough data available), don't bother passing the response to the 927 application. 928 929 If the authentication was tried, but failed, pass the response 930 to the application, maybe it can do better. */ |
900 if (APR_STATUS_IS_EOF(status) || 901 APR_STATUS_IS_EAGAIN(status)) { | 931 if (status) { |
902 return status; 903 } 904 } 905 906 if (!consumed_response) { 907 return (*request->handler)(request, 908 request->resp_bkt, 909 request->handler_baton, --- 145 unchanged lines hidden (view full) --- 1055 * 1056 * 4) When the server sends a error response, like 408 Request timeout. 1057 * This response should be passed to the application. 1058 * 1059 * If we see an EOF (due to either an expired timeout or the server 1060 * sending the SSL 'close notify' shutdown alert), we'll reset the 1061 * connection and open a new one. 1062 */ | 932 return status; 933 } 934 } 935 936 if (!consumed_response) { 937 return (*request->handler)(request, 938 request->resp_bkt, 939 request->handler_baton, --- 145 unchanged lines hidden (view full) --- 1085 * 1086 * 4) When the server sends a error response, like 408 Request timeout. 1087 * This response should be passed to the application. 1088 * 1089 * If we see an EOF (due to either an expired timeout or the server 1090 * sending the SSL 'close notify' shutdown alert), we'll reset the 1091 * connection and open a new one. 1092 */ |
1063 if (request->req_bkt || !request->written) { | 1093 if (request->req_bkt || !request->writing_started) { |
1064 const char *data; 1065 apr_size_t len; 1066 1067 status = serf_bucket_peek(conn->stream, &data, &len); 1068 1069 if (APR_STATUS_IS_EOF(status)) { 1070 reset_connection(conn, 1); 1071 status = APR_SUCCESS; --- 41 unchanged lines hidden (view full) --- 1113 } 1114 goto error; 1115 } 1116 1117 /* If our response handler says it can't do anything more, we now 1118 * treat that as a success. 1119 */ 1120 if (APR_STATUS_IS_EAGAIN(status)) { | 1094 const char *data; 1095 apr_size_t len; 1096 1097 status = serf_bucket_peek(conn->stream, &data, &len); 1098 1099 if (APR_STATUS_IS_EOF(status)) { 1100 reset_connection(conn, 1); 1101 status = APR_SUCCESS; --- 41 unchanged lines hidden (view full) --- 1143 } 1144 goto error; 1145 } 1146 1147 /* If our response handler says it can't do anything more, we now 1148 * treat that as a success. 1149 */ 1150 if (APR_STATUS_IS_EAGAIN(status)) { |
1151 /* It is possible that while reading the response, the ssl layer 1152 has prepared some data to send. If this was the last request, 1153 serf will not check for socket writability, so force this here. 1154 */ 1155 if (request_or_data_pending(&request, conn) && !request) { 1156 conn->dirty_conn = 1; 1157 conn->ctx->dirty_pollset = 1; 1158 } |
|
1121 status = APR_SUCCESS; 1122 goto error; 1123 } 1124 1125 /* If we received APR_SUCCESS, run this loop again. */ 1126 if (!status) { 1127 continue; 1128 } --- 48 unchanged lines hidden (view full) --- 1177 conn->completed_responses > conn->probable_keepalive_limit) { 1178 conn->probable_keepalive_limit = 0; 1179 } 1180 1181 /* If we just ran out of requests or have unwritten requests, then 1182 * update the pollset. We don't want to read from this socket any 1183 * more. We are definitely done with this loop, too. 1184 */ | 1159 status = APR_SUCCESS; 1160 goto error; 1161 } 1162 1163 /* If we received APR_SUCCESS, run this loop again. */ 1164 if (!status) { 1165 continue; 1166 } --- 48 unchanged lines hidden (view full) --- 1215 conn->completed_responses > conn->probable_keepalive_limit) { 1216 conn->probable_keepalive_limit = 0; 1217 } 1218 1219 /* If we just ran out of requests or have unwritten requests, then 1220 * update the pollset. We don't want to read from this socket any 1221 * more. We are definitely done with this loop, too. 1222 */ |
1185 if (request == NULL || !request->written) { | 1223 if (request == NULL || !request->writing_started) { |
1186 conn->dirty_conn = 1; 1187 conn->ctx->dirty_pollset = 1; 1188 status = APR_SUCCESS; 1189 goto error; 1190 } 1191 } 1192 1193error: --- 48 unchanged lines hidden (view full) --- 1242 /* If possible, get the error from the platform's socket layer and 1243 convert it to an APR status code. */ 1244 { 1245 apr_os_sock_t osskt; 1246 if (!apr_os_sock_get(&osskt, conn->skt)) { 1247 int error; 1248 apr_socklen_t l = sizeof(error); 1249 | 1224 conn->dirty_conn = 1; 1225 conn->ctx->dirty_pollset = 1; 1226 status = APR_SUCCESS; 1227 goto error; 1228 } 1229 } 1230 1231error: --- 48 unchanged lines hidden (view full) --- 1280 /* If possible, get the error from the platform's socket layer and 1281 convert it to an APR status code. */ 1282 { 1283 apr_os_sock_t osskt; 1284 if (!apr_os_sock_get(&osskt, conn->skt)) { 1285 int error; 1286 apr_socklen_t l = sizeof(error); 1287 |
1250 if (!getsockopt(osskt, SOL_SOCKET, SO_ERROR, (char*)&error, &l)) 1251 return APR_FROM_OS_ERROR(error); | 1288 if (!getsockopt(osskt, SOL_SOCKET, SO_ERROR, (char*)&error, 1289 &l)) { 1290 status = APR_FROM_OS_ERROR(error); 1291 1292 /* Handle fallback for multi-homed servers. 1293 1294 ### Improve algorithm to find better than just 'next'? 1295 1296 Current Windows versions already handle re-ordering for 1297 api users by using statistics on the recently failed 1298 connections to order the list of addresses. */ 1299 if (conn->completed_requests == 0 1300 && conn->address->next != NULL 1301 && (APR_STATUS_IS_ECONNREFUSED(status) 1302 || APR_STATUS_IS_TIMEUP(status) 1303 || APR_STATUS_IS_ENETUNREACH(status))) { 1304 1305 conn->address = conn->address->next; 1306 return reset_connection(conn, 1); 1307 } 1308 1309 return status; 1310 } |
1252 } 1253 } 1254#endif 1255 return APR_EGENERAL; 1256 } 1257 if ((events & APR_POLLOUT) != 0) { 1258 if ((status = write_to_connection(conn)) != APR_SUCCESS) 1259 return status; --- 77 unchanged lines hidden (view full) --- 1337 } 1338 1339 c = serf_connection_create(ctx, host_address, setup, setup_baton, 1340 closed, closed_baton, pool); 1341 1342 /* We're not interested in the path following the hostname. */ 1343 c->host_url = apr_uri_unparse(c->pool, 1344 &host_info, | 1311 } 1312 } 1313#endif 1314 return APR_EGENERAL; 1315 } 1316 if ((events & APR_POLLOUT) != 0) { 1317 if ((status = write_to_connection(conn)) != APR_SUCCESS) 1318 return status; --- 77 unchanged lines hidden (view full) --- 1396 } 1397 1398 c = serf_connection_create(ctx, host_address, setup, setup_baton, 1399 closed, closed_baton, pool); 1400 1401 /* We're not interested in the path following the hostname. */ 1402 c->host_url = apr_uri_unparse(c->pool, 1403 &host_info, |
1345 APR_URI_UNP_OMITPATHINFO); | 1404 APR_URI_UNP_OMITPATHINFO | 1405 APR_URI_UNP_OMITUSERINFO); |
1346 1347 /* Store the host info without the path on the connection. */ 1348 (void)apr_uri_parse(c->pool, c->host_url, &(c->host_info)); 1349 if (!c->host_info.port) { 1350 c->host_info.port = apr_uri_port_of_scheme(c->host_info.scheme); 1351 } 1352 1353 *conn = c; --- 110 unchanged lines hidden (view full) --- 1464 request->conn = conn; 1465 request->setup = setup; 1466 request->setup_baton = setup_baton; 1467 request->handler = NULL; 1468 request->respool = NULL; 1469 request->req_bkt = NULL; 1470 request->resp_bkt = NULL; 1471 request->priority = priority; | 1406 1407 /* Store the host info without the path on the connection. */ 1408 (void)apr_uri_parse(c->pool, c->host_url, &(c->host_info)); 1409 if (!c->host_info.port) { 1410 c->host_info.port = apr_uri_port_of_scheme(c->host_info.scheme); 1411 } 1412 1413 *conn = c; --- 110 unchanged lines hidden (view full) --- 1524 request->conn = conn; 1525 request->setup = setup; 1526 request->setup_baton = setup_baton; 1527 request->handler = NULL; 1528 request->respool = NULL; 1529 request->req_bkt = NULL; 1530 request->resp_bkt = NULL; 1531 request->priority = priority; |
1472 request->written = 0; | 1532 request->writing_started = 0; |
1473 request->ssltunnel = ssltunnel; 1474 request->next = NULL; | 1533 request->ssltunnel = ssltunnel; 1534 request->next = NULL; |
1535 request->auth_baton = NULL; |
|
1475 1476 return request; 1477} 1478 1479serf_request_t *serf_connection_request_create( 1480 serf_connection_t *conn, 1481 serf_request_setup_t setup, 1482 void *setup_baton) --- 27 unchanged lines hidden (view full) --- 1510 1, /* priority */ 1511 ssltunnelreq); 1512 1513 /* Link the new request after the last written request. */ 1514 iter = conn->requests; 1515 prev = NULL; 1516 1517 /* Find a request that has data which needs to be delivered. */ | 1536 1537 return request; 1538} 1539 1540serf_request_t *serf_connection_request_create( 1541 serf_connection_t *conn, 1542 serf_request_setup_t setup, 1543 void *setup_baton) --- 27 unchanged lines hidden (view full) --- 1571 1, /* priority */ 1572 ssltunnelreq); 1573 1574 /* Link the new request after the last written request. */ 1575 iter = conn->requests; 1576 prev = NULL; 1577 1578 /* Find a request that has data which needs to be delivered. */ |
1518 while (iter != NULL && iter->req_bkt == NULL && iter->written) { | 1579 while (iter != NULL && iter->req_bkt == NULL && iter->writing_started) { |
1519 prev = iter; 1520 iter = iter->next; 1521 } 1522 1523 /* A CONNECT request to setup an ssltunnel has absolute priority over all 1524 other requests on the connection, so: 1525 a. add it first to the queue 1526 b. ensure that other priority requests are added after the CONNECT --- 42 unchanged lines hidden (view full) --- 1569 1570apr_status_t serf_request_cancel(serf_request_t *request) 1571{ 1572 return cancel_request(request, &request->conn->requests, 0); 1573} 1574 1575apr_status_t serf_request_is_written(serf_request_t *request) 1576{ | 1580 prev = iter; 1581 iter = iter->next; 1582 } 1583 1584 /* A CONNECT request to setup an ssltunnel has absolute priority over all 1585 other requests on the connection, so: 1586 a. add it first to the queue 1587 b. ensure that other priority requests are added after the CONNECT --- 42 unchanged lines hidden (view full) --- 1630 1631apr_status_t serf_request_cancel(serf_request_t *request) 1632{ 1633 return cancel_request(request, &request->conn->requests, 0); 1634} 1635 1636apr_status_t serf_request_is_written(serf_request_t *request) 1637{ |
1577 if (request->written && !request->req_bkt) | 1638 if (request->writing_started && !request->req_bkt) |
1578 return APR_SUCCESS; 1579 1580 return APR_EBUSY; 1581} 1582 1583apr_pool_t *serf_request_get_pool(const serf_request_t *request) 1584{ 1585 return request->respool; --- 98 unchanged lines hidden --- | 1639 return APR_SUCCESS; 1640 1641 return APR_EBUSY; 1642} 1643 1644apr_pool_t *serf_request_get_pool(const serf_request_t *request) 1645{ 1646 return request->respool; --- 98 unchanged lines hidden --- |