-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
problems sending large data on macOS over unix domain sockets #4919
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
Comments
What puzzles me the most about this bug is that very little internals even know what kind of socket it is working with and most of the code is just agnostic and work with "a socket" independent of what kind of connection it is. It might imply that unix domain sockets somehow behaves differently than SOCK_STREAM ones do - on macos. Research is required. The bug triggers if the custom header is larger than 8100 bytes something. Then only the first piece of the request is sent and nothing more is ever sent. The socket just doesn't seem to signal itself as writable anymore... |
The bug triggers on macOS if the custom header is larger than 8100 bytes something. Then only the first piece of the request is sent and nothing more is ever sent. Clearly the logic for handling a "split" request send is broken, and I believe it is broken on all platforms. This bug also reproduces on Linux but then at around ~220K so the custom header needs to be made much larger there. |
I arrived at this little patch that lets me write a simple test case for this problem using the regular test suite, which makes it easier to work on a fix: diff --git a/lib/http.c b/lib/http.c
index 324dd7252..814d69fd2 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1227,12 +1227,25 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer **inp,
return result;
}
memcpy(data->state.ulbuf, ptr, sendsize);
ptr = data->state.ulbuf;
}
- else
+ else {
+#ifdef CURLDEBUG
+ /* Allow debug builds override this logic to force short initial sends */
+ char *p = getenv("CURL_SMALLREQSEND");
+ if(p) {
+ size_t altsize = (size_t)strtoul(p, NULL, 10);
+ if(altsize)
+ sendsize = CURLMIN(size, altsize);
+ else
+ sendsize = size;
+ }
+ else
+#endif
sendsize = size;
+ }
result = Curl_write(conn, sockfd, ptr, sendsize, &amount);
if(!result) {
/*
|
(I received this bug report by a user who shall remain anonymous)
curl 7.68.0 seems to have problems sending large data on macOS over unix domain sockets. You can reproduce by using netcat as a server like this:
And then invoke curl:
(This has curl send a very long single header that ends with OK)
If you look at the output from curl, you’ll notice that it never gets around to sending the
OK
part of the string. This seems to be specific to recent curls and to macOSTaking a look at dtrace it seems like curl stops asking select whether the socket is writable
(This is a printout of the send calls and then the fdsets passed to select, the relevant FD is 5 so 0x20)
The text was updated successfully, but these errors were encountered: