lib: move 'done' parameter to SingleRequests

A transfer may do several `SingleRequest`s for its success. This happens
regularly for authentication, follows and retries on failed connections.
The "readwrite()" calls and functions connected to those carried a `bool
*done` parameter to indicate that the current `SingleRequest` is over.
This may happen before `upload_done` or `download_done` bits of
`SingleRequest` are set.

The problem with that is now `write_resp()` protocol handlers are
invoked in places where the `bool *done` cannot be passed up to the
caller. Instead of being a bool in the call chain, it needs to become a
member of `SingleRequest`, reflecting its state.

This removes the `bool *done` parameter and adds the `done` bit to
`SingleRequest` instead. It adds `Curl_req_soft_reset()` for using a
`SingleRequest` in a follow up, clearing `done` and other
flags/counters.

Closes #13096
This commit is contained in:
Stefan Eissing 2024-03-11 12:35:07 +01:00 committed by Daniel Stenberg
parent 6aeb729b5c
commit 4e4e8af1f6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
16 changed files with 96 additions and 100 deletions

View file

@ -207,7 +207,6 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
CURLcode result = CURLE_OK;
if(0 == k->bodywrites) {
bool done = FALSE;
#if defined(USE_NTLM)
struct connectdata *conn = data->conn;
if(conn->bits.close &&
@ -235,12 +234,12 @@ static int hyper_body_chunk(void *userdata, const hyper_buf *chunk)
}
if(data->state.hconnect && (data->req.httpcode/100 != 2) &&
data->state.authproxy.done) {
done = TRUE;
data->req.done = TRUE;
result = CURLE_OK;
}
else
result = Curl_http_firstwrite(data, data->conn, &done);
if(result || done) {
result = Curl_http_firstwrite(data);
if(result || data->req.done) {
infof(data, "Return early from hyper_body_chunk");
data->state.hresult = result;
return HYPER_ITER_BREAK;
@ -338,7 +337,6 @@ static CURLcode empty_header(struct Curl_easy *data)
CURLcode Curl_hyper_stream(struct Curl_easy *data,
struct connectdata *conn,
int *didwhat,
bool *done,
int select_res)
{
hyper_response *resp = NULL;
@ -382,7 +380,6 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
h->write_waker = NULL;
}
*done = FALSE;
do {
hyper_task_return_type t;
task = hyper_executor_poll(h->exec);
@ -425,7 +422,7 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
break;
}
}
*done = TRUE;
data->req.done = TRUE;
hyper_error_free(hypererr);
break;
}
@ -434,12 +431,11 @@ CURLcode Curl_hyper_stream(struct Curl_easy *data,
hyper_task_free(task);
if((userdata_t)userdata == USERDATA_RESP_BODY) {
/* end of transfer */
*done = TRUE;
data->req.done = TRUE;
infof(data, "hyperstream is done");
if(!k->bodywrites) {
/* hyper doesn't always call the body write callback */
bool stilldone;
result = Curl_http_firstwrite(data, data->conn, &stilldone);
result = Curl_http_firstwrite(data);
}
break;
}