-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
HTTP connection closed seemingly related to ioctl(0, TIOCGWINSZ) #17061
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
With this additional patch ... diff --git a/src/terminal.c b/src/terminal.c
index 30d902e95..0f54ee23a 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -26,6 +26,7 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
+#include <errno.h>
#include "terminal.h"
#include "curlx.h"
@@ -47,6 +48,7 @@ unsigned int get_terminal_columns(void)
{
unsigned int width = 0;
char *colp = curl_getenv("COLUMNS");
+ int saved = errno;
if(colp) {
curl_off_t num;
const char *p = colp;
@@ -85,6 +87,7 @@ unsigned int get_terminal_columns(void)
if(cols >= 0 && cols < 10000)
width = (unsigned int)cols;
}
+ errno = saved;
if(!width)
width = 79;
return width; /* 79 for unknown, might also be tiny or enormous */ I get:
which makes more sense in that maybe the failing |
Yeah, I was looking for a "leftover" errno when the terminal width is checked. But I did not see why this is checked since your curl invocation suppresses the progress bar who would need it. Maybe @bagder has an idea... |
This patch avoids the issue: diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c
index 7a575c98f..2dc5aed86 100644
--- a/src/tool_cb_wrt.c
+++ b/src/tool_cb_wrt.c
@@ -364,7 +364,10 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata)
if(config->nobuffer) {
/* output buffering disabled */
- int res = fflush(outs->stream);
+ int res;
+ do {
+ res = fflush(outs->stream);
+ } while (res && errno == EINTR);
if(res)
return CURL_WRITEFUNC_ERROR;
} |
Issue report and patch fix by @nigoroll refs curl#17061
Thanks! Converted into #17063. |
Report-and-patch-by: Nils Goroll Fixes curl#17061 Closes curl#17063
Report-and-patch-by: Nils Goroll Fixes curl#17061 Closes curl#17063
I did this
Only for context, feel free to skip
I am using curl for regression testing of SLASH/ with a delivery filter (VDP) on the varnish-cache end which deliberately panics when the written http body length does not match the expected value. The testing goal is to ensure that the storage engine always delivers the right amount of data, so for this testing scenario errors which are otherwise completely normal (like a short body write due to a connection closure from the client side) can not safely be ignored, as doing so would hide actual errors. In other words, for this testing regime I need a client which always does the right thing.
Calling curl
The main part of the test script executes 30 parallel instances of curl with 50001 urls in the argument list:
The details regarding the
p
,l
andpp
variables should not matter, but feel free to look at the full script.I expected the following
I expected curl to always read the full response body and not close the connection prematurely.
Sometimes and seemingly random, the curl invocation triggers a short write on the server side:
Originally, I would see
client returned ERROR on write of ...
with curl.To better understand the issue, I patched it slightly:
With this, the error message is:
So
errno=ENOTTY
with a signed return value of-1
.To be sure about the error, I also ran curl in strace:
So it really looks like the issue would indeed be caused by
ioctl(0, TIOCGWINSZ)
seemingly called at random.I see where this is happening in the code base, but I do not understand why apparently out of nowhere and at random points in time.
curl/libcurl version
Originally seen with stock-debian:
Then reproduced with current HEAD 3fbabec:
operating system
The text was updated successfully, but these errors were encountered: