diff options
author | John Schroeder <john@schroederspace.com> | 2019-11-26 09:16:19 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-11-26 09:17:52 +0100 |
commit | 9a2cbf30b81a2b57149bb20e78e2e4cb5c2ff389 (patch) | |
tree | 5c31ee04911407d843f17c31db412988f3154769 /src/tool_cb_rea.c | |
parent | 7cf18b05e04bbb0f08c74d2567b0648f6c31a952 (diff) | |
download | curl-9a2cbf30b81a2b57149bb20e78e2e4cb5c2ff389.tar.gz |
curl: fix --upload-file . hangs if delay in STDIN
Attempt to unpause a busy read in the CURLOPT_XFERINFOFUNCTION.
When uploading from stdin in non-blocking mode, a delay in reading
the stream (EAGAIN) causes curl to pause sending data
(CURL_READFUNC_PAUSE). Prior to this change, a busy read was
detected and unpaused only in the CURLOPT_WRITEFUNCTION handler.
This change performs the same busy read handling in a
CURLOPT_XFERINFOFUNCTION handler.
Fixes #2051
Closes #4599
Reported-by: bdry on github
Diffstat (limited to 'src/tool_cb_rea.c')
-rw-r--r-- | src/tool_cb_rea.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index 06f60eca7..03ed4a467 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -27,6 +27,7 @@ #include "tool_cfgable.h" #include "tool_cb_rea.h" +#include "tool_operate.h" #include "memdebug.h" /* keep this as LAST include */ @@ -52,3 +53,28 @@ size_t tool_read_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) in->config->readbusy = FALSE; return (size_t)rc; } + +/* +** callback for CURLOPT_XFERINFOFUNCTION used to unpause busy reads +*/ + +int tool_readbusy_cb(void *clientp, + curl_off_t dltotal, curl_off_t dlnow, + curl_off_t ultotal, curl_off_t ulnow) +{ + struct per_transfer *per = clientp; + struct OutStruct *outs = &per->outs; + struct OperationConfig *config = outs->config; + + (void)dltotal; /* unused */ + (void)dlnow; /* unused */ + (void)ultotal; /* unused */ + (void)ulnow; /* unused */ + + if(config->readbusy) { + config->readbusy = FALSE; + curl_easy_pause(per->curl, CURLPAUSE_CONT); + } + + return per->noprogress? 0 : CURL_PROGRESSFUNC_CONTINUE; +} |