Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cf-socket, simulate slow/blocked receives in debug #12035

Closed
wants to merge 1 commit into from

Conversation

icing
Copy link
Contributor

@icing icing commented Oct 5, 2023

Add 2 env variables for non-UDP sockets:

  1. CURL_DBG_SOCK_RBLOCK: percentage of receive calls that randomly should return EAGAIN
  2. CURL_DBG_SOCK_RMAX: max amount of bytes read from socket

similar to the existing CURL_DBG_SOCK_WBLOCK and CURL_DBG_SOCK_WPARTIAL. Documentation to be added once Jay's doc PR has landed.

Why?

Tests were run locally on a macOS dev machine with different value for the variables. Only one var was used in tests to isolate problems.

CURL_DBG_SOCK_RBLOCK

X percent of socket recv() calls return CURLE_AGAIN right away.

Interesting for cases where a subsequent read would normally be successful, but now is not.

CURL_DBG_SOCK_RBLOCK Failures
0 -
10 823 869 907 2302
50 823 869 907 2302
90 823 869 907 1474 2302

CURL_DBG_SOCK_RMAX

Calls to socket recv() with a buffer limit the length of the buffer to this value.

Interesting for cases where the network is slow or where the server sends in strange chunks or where a middle box is involved that buffers differently. Note that low values just trigger edge cases in taking in data deterministically. The failures could happen on "real" data as well, only with lower probability.

CURL_DBG_SOCK_RMAX Failures Protocol
500 -
250 -
125 -
120 -
118 -
117 571 RTSP
116 571 RTSP
115 571 RTSP
110 571 RTSP
100 571 RTSP
75 571 RTSP
50 571 RTSP
48 571 RTSP
45 571 RTSP
44 571 RTSP
43 571 3100 RTSP
37 571 3100 RTSP
25 571 3100 RTSP
23 568 571 572 2302 3100 RTSP WebSockets
20 568 571 572 577 3100 RTSP WebSockets
12 567 568 569 570 571 572 577 1540 3100 RTSP WebSockets HTTP
6 457 567 568 569 570 571 572 577 1540 3100 RTSP WebSockets HTTP
5 567 577 571 568 569 570 572 1540 3100 RTSP WebSockets HTTP
4 567 569 571 568 570 572 577 981 982 1540 2302 3100 RTSP WebSockets HTTP
3 232 457 567 568 569 570 571 572 577 980 983 1540 2302 3100 RTSP WebSockets HTTP
2 457 567 568 569 570 571 577 572 981 982 1190 1192 1194 1452 1540 2204 2302 3018 3100 RTSP WebSockets HTTP IMAP POP3
1 232 457 567 568 570 569 571 572 577 980 981 982 983 1190 1191 1192 1193 1194 1195 1198 1199 1452 1474 1540 1916 1917 2201 2204 2302 3017 3018 3100 RTSP WebSockets HTTP IMAP POP3 MQTT TELNET

command run:

make -j20 && (cd tests && make -j20 && ENV_VAR=xxx ./runtests.pl -a -j20)

curl build used:

curl 8.4.0-DEV (x86_64-apple-darwin22.6.0) libcurl/8.4.0-DEV OpenSSL/3.0.9 zlib/1.2.11 brotli/1.0.9 zstd/1.5.5 c-ares/1.19.1 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.56.0 ngtcp2/0.19.1 nghttp3/0.15.0 librtmp/2.3
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli Debug GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM SPNEGO SSL threadsafe TLS-SRP TrackMemory UnixSockets zstd

add 2 env variables for non-UDP sockets:
1. CURL_DBG_SOCK_RBLOCK: percentage of receive calls that randomly
   should return EAGAIN
2. CURL_DBG_SOCK_RMAX: max amount of bytes read from socket
icing added a commit to icing/curl that referenced this pull request Oct 7, 2023
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with curl#12035 and various small receive
  sizes where current master fails
icing added a commit to icing/curl that referenced this pull request Oct 8, 2023
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with curl#12035 and various small receive
  sizes where current master fails
@icing icing requested a review from bagder October 8, 2023 09:02
@bagder bagder closed this in b9c78ee Oct 8, 2023
icing added a commit to icing/curl that referenced this pull request Oct 8, 2023
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with curl#12035 and various small receive
  sizes where current master fails
icing added a commit to icing/curl that referenced this pull request Oct 10, 2023
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with curl#12035 and various small receive
  sizes where current master fails
bagder pushed a commit that referenced this pull request Oct 21, 2023
- fix HTTP header parsing to report incomplete
  lines it buffers as consumed!
- re-implement the RTP parser for interleave RTP
  messages for robustness. It is now keeping its
  state at the connection
- RTSP protocol handler "readwrite" implementation
  now tracks if the response is before/in/after
  header parsing or "in" a bod by calling
  "Curl_http_readwrite_headers()" itself. This
  allows it to know when non-RTP bytes are "junk"
  or HEADER or BODY.
- tested with #12035 and various small receive
  sizes where current master fails

Closes #12052
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants