diff options
author | Stefan Eissing <stefan@eissing.org> | 2023-02-08 10:26:58 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-02-09 09:13:30 +0100 |
commit | 3de3ea6a646687de2bf4154ce647485a84e1c6f9 (patch) | |
tree | 2750c4c0af3d745157e6ff5548039027ba7cca81 /lib/http2.c | |
parent | 8c762f59983a3e9e2b80fdb34aa5e08f1d9a1c7d (diff) | |
download | curl-3de3ea6a646687de2bf4154ce647485a84e1c6f9.tar.gz |
HTTP/[23]: continue upload when state.drain is set
- as reported in #10433, HTTP/2 uploads may stall when a response is
received before the upload is done. This happens when the
data->state.drain is set for such a transfer, as the special handling
in transfer.c from then on only cared about downloads.
- add continuation of uploads, if applicable, in this case.
- add pytest case test_07_12_upload_seq_large to reproduce this scenario
(although, current nghttp2 implementation is using drain less often)
Reported-by: Lucas Pardue
Fixes #10433
Closes #10443
Diffstat (limited to 'lib/http2.c')
-rw-r--r-- | lib/http2.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/http2.c b/lib/http2.c index d5eed385e..46fc74645 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -592,11 +592,12 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header) static void drained_transfer(struct Curl_cfilter *cf, struct Curl_easy *data) { - struct cf_h2_ctx *ctx = cf->ctx; - - DEBUGASSERT(ctx->drain_total >= data->state.drain); - ctx->drain_total -= data->state.drain; - data->state.drain = 0; + if(data->state.drain) { + struct cf_h2_ctx *ctx = cf->ctx; + DEBUGASSERT(ctx->drain_total > 0); + ctx->drain_total--; + data->state.drain = 0; + } } /* @@ -605,11 +606,12 @@ static void drained_transfer(struct Curl_cfilter *cf, static void drain_this(struct Curl_cfilter *cf, struct Curl_easy *data) { - struct cf_h2_ctx *ctx = cf->ctx; - - data->state.drain++; - ctx->drain_total++; - DEBUGASSERT(ctx->drain_total >= data->state.drain); + if(!data->state.drain) { + struct cf_h2_ctx *ctx = cf->ctx; + data->state.drain = 1; + ctx->drain_total++; + DEBUGASSERT(ctx->drain_total > 0); + } } static struct Curl_easy *h2_duphandle(struct Curl_cfilter *cf, @@ -1575,8 +1577,6 @@ static ssize_t http2_handle_stream_close(struct Curl_cfilter *cf, } } - DEBUGASSERT(data->state.drain == 0); - /* Reset to FALSE to prevent infinite loop in readwrite_data function. */ stream->closed = FALSE; if(stream->error == NGHTTP2_REFUSED_STREAM) { @@ -1929,8 +1929,9 @@ static ssize_t cf_h2_recv(struct Curl_cfilter *cf, struct Curl_easy *data, drain_this(cf, data); Curl_expire(data, 0, EXPIRE_RUN_NOW); } - else + else { drained_transfer(cf, data); + } nread = retlen; DEBUGF(LOG_CF(data, cf, "[h2sid=%u] cf_h2_recv -> %zd", |