From be8d2b037da92e39044366fbbaf2dd2e6e30685b Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 29 Jun 2022 17:45:32 -0700 Subject: [PATCH] hyper: use wakers for curl pause/resume Closes #9070 --- lib/c-hyper.c | 15 ++++++++++++--- lib/c-hyper.h | 1 + lib/easy.c | 10 ++++++++++ tests/data/DISABLED | 4 ---- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/c-hyper.c b/lib/c-hyper.c index 69b904e531..93b912c47c 100644 --- a/lib/c-hyper.c +++ b/lib/c-hyper.c @@ -692,9 +692,18 @@ static int uploadstreamed(void *userdata, hyper_context *ctx, data->state.hresult = result; return HYPER_POLL_ERROR; } - if(!fillcount) - /* done! */ - *chunk = NULL; + if(!fillcount) { + if((data->req.keepon & KEEP_SEND_PAUSE) != KEEP_SEND_PAUSE) + /* done! */ + *chunk = NULL; + else { + /* paused, save a waker */ + if(data->hyp.send_body_waker) + hyper_waker_free(data->hyp.send_body_waker); + data->hyp.send_body_waker = hyper_context_waker(ctx); + return HYPER_POLL_PENDING; + } + } else { hyper_buf *copy = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount); if(copy) diff --git a/lib/c-hyper.h b/lib/c-hyper.h index 91a62619c3..70507ad2a4 100644 --- a/lib/c-hyper.h +++ b/lib/c-hyper.h @@ -36,6 +36,7 @@ struct hyptransfer { const hyper_executor *exec; hyper_task *endtask; hyper_waker *exp100_waker; + hyper_waker *send_body_waker; }; size_t Curl_hyper_recv(void *userp, hyper_context *ctx, diff --git a/lib/easy.c b/lib/easy.c index 704a59df62..06a94b01b0 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -1132,6 +1132,16 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action) } } +#ifdef USE_HYPER + if(!(newstate & KEEP_SEND_PAUSE)) { + /* need to wake the send body waker */ + if(data->hyp.send_body_waker) { + hyper_waker_wake(data->hyp.send_body_waker); + data->hyp.send_body_waker = NULL; + } + } +#endif + /* if there's no error and we're not pausing both directions, we want to have this handle checked soon */ if((newstate & (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) != diff --git a/tests/data/DISABLED b/tests/data/DISABLED index 00ebebc949..4d62fb615e 100644 --- a/tests/data/DISABLED +++ b/tests/data/DISABLED @@ -69,10 +69,6 @@ 565 579 587 -670 -671 -672 -673 # 1021 re-added here due to flakiness 1021 1117 -- 2.47.3