mirror of
https://github.com/curl/curl.git
synced 2026-08-26 03:53:32 +03:00
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:
parent
6aeb729b5c
commit
4e4e8af1f6
16 changed files with 96 additions and 100 deletions
11
lib/multi.c
11
lib/multi.c
|
|
@ -1843,7 +1843,6 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||
bool async;
|
||||
bool protocol_connected = FALSE;
|
||||
bool dophase_done = FALSE;
|
||||
bool done = FALSE;
|
||||
CURLMcode rc;
|
||||
CURLcode result = CURLE_OK;
|
||||
timediff_t recv_timeout_ms;
|
||||
|
|
@ -2405,9 +2404,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||
}
|
||||
|
||||
/* read/write data if it is ready to do so */
|
||||
result = Curl_readwrite(data, &done);
|
||||
result = Curl_readwrite(data);
|
||||
|
||||
if(done || (result == CURLE_RECV_ERROR)) {
|
||||
if(data->req.done || (result == CURLE_RECV_ERROR)) {
|
||||
/* If CURLE_RECV_ERROR happens early enough, we assume it was a race
|
||||
* condition and the server closed the reused connection exactly when
|
||||
* we wanted to use it, so figure out if that is indeed the case.
|
||||
|
|
@ -2422,7 +2421,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||
/* if we are to retry, set the result to OK and consider the
|
||||
request as done */
|
||||
result = CURLE_OK;
|
||||
done = TRUE;
|
||||
data->req.done = TRUE;
|
||||
}
|
||||
}
|
||||
else if((CURLE_HTTP2_STREAM == result) &&
|
||||
|
|
@ -2442,7 +2441,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||
as done */
|
||||
retry = TRUE;
|
||||
result = CURLE_OK;
|
||||
done = TRUE;
|
||||
data->req.done = TRUE;
|
||||
}
|
||||
else
|
||||
result = ret;
|
||||
|
|
@ -2464,7 +2463,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
|
|||
Curl_posttransfer(data);
|
||||
multi_done(data, result, TRUE);
|
||||
}
|
||||
else if(done) {
|
||||
else if(data->req.done) {
|
||||
|
||||
/* call this even if the readwrite function returned error */
|
||||
Curl_posttransfer(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue