Repository navigation
Conversation
c8b07cc to
ce83a2a
Compare
- Curl_write_plain/Curl_read_plain have been eliminated. Last code use now uses Curl_conn_send/recv so that requests use conn->send/revc callbacks which defaults to cfilters use. - Curl_recv_plain/Curl_send_plain have been internalized in cf-socket.c. - USE_RECV_BEFORE_SEND_WORKAROUND (active on Windows) has been moved into cf-socket.c. The pre_recv buffer is held at the socket filter context. `postponed_data` structures have been removed from `connectdata`. - the hanger in HTTP/2 request handling was a result of read buffering on all sends and the multi handling is not prepared for this. The following happens: - multi preforms on a HTTP/2 easy handle - h2 reads and processes data - this leads to a send of h2 data - which receives and buffers before the send - h2 returns - multi selects on the socket, but no data arrives (its in the buffer already) the workaround now receives data in a loop as long as there is something in the buffer. The real fix would be for multi to change, so that `data_pending` is evaluated before deciding to wait on the socket. io_buffer, optional, in cf-socket.c, http/2 sets state.drain if lower filter have pending data. This io_buffer is only available/used when the -DUSE_RECV_BEFORE_SEND_WORKAROUND is active, e.g. on Windows configurations. It also maintains the original checks on protocol handler being HTTP and conn->send/recv not being replaced. The HTTP/2 (nghttp2) cfilter now sets data->state.drain when it finds out that the "lower" filter chain has still pending data at the end of its IO operation. This prevents the processing from becoming stalled.
ce83a2a to
cf3bbea
Compare
|
Sorry that I did not have time to review this. I did test it and it seems to be working but I always see a lot more of drain in the verbose output: Which is probably this so maybe it's expected now:
Another website that can be used to reproduce the issue before this fix is Though this PR fixes the issue and is a welcome improvement I am going to propose in a separate PR disabling by default USE_RECV_BEFORE_SEND_WORKAROUND in Windows builds. It has led to bugs that are hard to track down and that there is no easy way to test for. Like, this looks fixed but I can't determine for certain if it's fixed in all scenarios which is a problem. I'm basically running commands thousands of times and getting good feedback. I think that if buffering of socket data improves we can revisit enabling it by default. |
|
@jay thanks for the testing. I agree that this windows workaround is hard to verify for correctness. Building on top of this PR with improvements is most welcome. I believe a general buffering implementation in the socket filters is a Good Thing, if we can get a grip on the "pending" and "drain" handling. |
|
Thanks! |
- Curl_write_plain/Curl_read_plain have been eliminated. Last code use now uses Curl_conn_send/recv so that requests use conn->send/revc callbacks which defaults to cfilters use. - Curl_recv_plain/Curl_send_plain have been internalized in cf-socket.c. - USE_RECV_BEFORE_SEND_WORKAROUND (active on Windows) has been moved into cf-socket.c. The pre_recv buffer is held at the socket filter context. `postponed_data` structures have been removed from `connectdata`. - the hanger in HTTP/2 request handling was a result of read buffering on all sends and the multi handling is not prepared for this. The following happens: - multi preforms on a HTTP/2 easy handle - h2 reads and processes data - this leads to a send of h2 data - which receives and buffers before the send - h2 returns - multi selects on the socket, but no data arrives (its in the buffer already) the workaround now receives data in a loop as long as there is something in the buffer. The real fix would be for multi to change, so that `data_pending` is evaluated before deciding to wait on the socket. io_buffer, optional, in cf-socket.c, http/2 sets state.drain if lower filter have pending data. This io_buffer is only available/used when the -DUSE_RECV_BEFORE_SEND_WORKAROUND is active, e.g. on Windows configurations. It also maintains the original checks on protocol handler being HTTP and conn->send/recv not being replaced. The HTTP/2 (nghttp2) cfilter now sets data->state.drain when it finds out that the "lower" filter chain has still pending data at the end of its IO operation. This prevents the processing from becoming stalled. Closes curl#10280
- fix socket/sockindex confusion on writes: The callstack used to end with `Curl_write_plain()` accepting a socket till 7.87.0. This call got swapped for `Curl_conn_send()`, expecting a sockindex. `socket_write()` was updated accordingly. Its callers missed it and continued operating on sockets: `do_sec_send()`, `sec_write()`, passing it down the stack and `Curl_conn_send()` resolving it as if it were a sockindex. It affected FTP Kerberos authentication. Discovered through MSVC warnings: ``` curl\lib\krb5.c(652,28): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(654,28): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(656,26): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(657,26): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(665,24): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(666,24): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data ``` Ref: https://github.com/curl/curl/actions/runs/11846599621/job/33014592805#step:9:32 Follow-up to 5651a36 #10280 Bug: #15549 (comment) Fixes #15582 - fix uninitialized buffer: ``` curl\lib\krb5.c(288,1): warning C4701: potentially uninitialized local variable '_gssresp' used ``` Ref: https://github.com/curl/curl/actions/runs/11848626645/job/33020501026?pr=15585#step:9:31 - silence unreachable code compiler warning: ``` curl\lib\krb5.c(370,1): warning C4702: unreachable code ``` Ref: https://github.com/curl/curl/actions/runs/11848626645/job/33020501026?pr=15585#step:9:30 Closes #15585
- fix socket/sockindex confusion on writes: The callstack used to end with `Curl_write_plain()` accepting a socket till 7.87.0. This call got swapped for `Curl_conn_send()`, expecting a sockindex. `socket_write()` was updated accordingly. Its callers missed it and continued operating on sockets: `do_sec_send()`, `sec_write()`, passing it down the stack and `Curl_conn_send()` resolving it as if it were a sockindex. It affected FTP Kerberos authentication. Discovered through MSVC warnings: ``` curl\lib\krb5.c(652,28): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(654,28): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(656,26): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(657,26): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(665,24): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data curl\lib\krb5.c(666,24): warning C4244: 'function': conversion from 'curl_socket_t' to 'int', possible loss of data ``` Ref: https://github.com/curl/curl/actions/runs/11846599621/job/33014592805#step:9:32 Follow-up to 5651a36 curl#10280 Bug: curl#15549 (comment) Fixes curl#15582 - fix uninitialized buffer: ``` curl\lib\krb5.c(288,1): warning C4701: potentially uninitialized local variable '_gssresp' used ``` Ref: https://github.com/curl/curl/actions/runs/11848626645/job/33020501026?pr=15585#step:9:31 - silence unreachable code compiler warning: ``` curl\lib\krb5.c(370,1): warning C4702: unreachable code ``` Ref: https://github.com/curl/curl/actions/runs/11848626645/job/33020501026?pr=15585#step:9:30 Closes curl#15585
Refactoring of the diverse Curl_send/recv_plain() and Curl_write/read_plain() functions, fix of stalling HTTP/2 processing when USE_RECV_BEFORE_SEND_WORKAROUND is in effect. Refs #10253.
internalised in
cf-socket.c.data->state.drainif, at the end of an operation, the "lower" filter chain reports pending data. This fixes the stalling of h2 processing when this feature is in effect.