mirror of
https://github.com/curl/curl.git
synced 2026-07-31 07:08:05 +03:00
h2/h3: replace state.drain counter with state.dselect_bits
- `drain` was used by http/2 and http/3 implementations to indicate that the transfer requires send/recv independant from its socket poll state. Intended as a counter, it was used as bool flag only. - a similar mechanism exists on `connectdata->cselect_bits` where specific protocols can indicate something similar, only for the whole connection. - `cselect_bits` are cleard in transfer.c on use and, importantly, also set when the transfer loop expended its `maxloops` tries. `drain` was not cleared by transfer and the http2/3 implementations had to take care of that. - `dselect_bits` is cleared *and* set by the transfer loop. http2/3 does no longer clear it, only set when new events happen. This change unifies the handling of socket poll overrides, extending `cselect_bits` by a easy handle specific value and a common treatment in transfers. Closes #11005
This commit is contained in:
parent
a97e4eb95f
commit
cab2d56ea5
8 changed files with 152 additions and 170 deletions
|
|
@ -753,7 +753,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
|
|||
|
||||
if(maxloops <= 0) {
|
||||
/* we mark it as read-again-please */
|
||||
conn->cselect_bits = CURL_CSELECT_IN;
|
||||
data->state.dselect_bits = CURL_CSELECT_IN;
|
||||
*comeback = TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1065,40 +1065,36 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||
CURLcode result;
|
||||
struct curltime now;
|
||||
int didwhat = 0;
|
||||
int select_bits;
|
||||
|
||||
curl_socket_t fd_read;
|
||||
curl_socket_t fd_write;
|
||||
int select_res = conn->cselect_bits;
|
||||
|
||||
conn->cselect_bits = 0;
|
||||
|
||||
/* only use the proper socket if the *_HOLD bit is not set simultaneously as
|
||||
then we are in rate limiting state in that transfer direction */
|
||||
|
||||
if((k->keepon & KEEP_RECVBITS) == KEEP_RECV)
|
||||
fd_read = conn->sockfd;
|
||||
else
|
||||
fd_read = CURL_SOCKET_BAD;
|
||||
|
||||
if((k->keepon & KEEP_SENDBITS) == KEEP_SEND)
|
||||
fd_write = conn->writesockfd;
|
||||
else
|
||||
fd_write = CURL_SOCKET_BAD;
|
||||
|
||||
#if defined(USE_HTTP2) || defined(USE_HTTP3)
|
||||
if(data->state.drain) {
|
||||
select_res |= CURL_CSELECT_IN;
|
||||
DEBUGF(infof(data, "Curl_readwrite: forcibly told to drain data"));
|
||||
if((k->keepon & KEEP_SENDBITS) == KEEP_SEND)
|
||||
select_res |= CURL_CSELECT_OUT;
|
||||
if(data->state.dselect_bits) {
|
||||
select_bits = data->state.dselect_bits;
|
||||
data->state.dselect_bits = 0;
|
||||
}
|
||||
#endif
|
||||
else if(conn->cselect_bits) {
|
||||
select_bits = conn->cselect_bits;
|
||||
conn->cselect_bits = 0;
|
||||
}
|
||||
else {
|
||||
curl_socket_t fd_read;
|
||||
curl_socket_t fd_write;
|
||||
/* only use the proper socket if the *_HOLD bit is not set simultaneously
|
||||
as then we are in rate limiting state in that transfer direction */
|
||||
if((k->keepon & KEEP_RECVBITS) == KEEP_RECV)
|
||||
fd_read = conn->sockfd;
|
||||
else
|
||||
fd_read = CURL_SOCKET_BAD;
|
||||
|
||||
if(!select_res) /* Call for select()/poll() only, if read/write/error
|
||||
status is not known. */
|
||||
select_res = Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write, 0);
|
||||
if((k->keepon & KEEP_SENDBITS) == KEEP_SEND)
|
||||
fd_write = conn->writesockfd;
|
||||
else
|
||||
fd_write = CURL_SOCKET_BAD;
|
||||
|
||||
if(select_res == CURL_CSELECT_ERR) {
|
||||
select_bits = Curl_socket_check(fd_read, CURL_SOCKET_BAD, fd_write, 0);
|
||||
}
|
||||
|
||||
if(select_bits == CURL_CSELECT_ERR) {
|
||||
failf(data, "select/poll returned error");
|
||||
result = CURLE_SEND_ERROR;
|
||||
goto out;
|
||||
|
|
@ -1106,7 +1102,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||
|
||||
#ifdef USE_HYPER
|
||||
if(conn->datastream) {
|
||||
result = conn->datastream(data, conn, &didwhat, done, select_res);
|
||||
result = conn->datastream(data, conn, &didwhat, done, select_bits);
|
||||
if(result || *done)
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -1115,14 +1111,14 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||
/* We go ahead and do a read if we have a readable socket or if
|
||||
the stream was rewound (in which case we have data in a
|
||||
buffer) */
|
||||
if((k->keepon & KEEP_RECV) && (select_res & CURL_CSELECT_IN)) {
|
||||
if((k->keepon & KEEP_RECV) && (select_bits & CURL_CSELECT_IN)) {
|
||||
result = readwrite_data(data, conn, k, &didwhat, done, comeback);
|
||||
if(result || *done)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* If we still have writing to do, we check if we have a writable socket. */
|
||||
if((k->keepon & KEEP_SEND) && (select_res & CURL_CSELECT_OUT)) {
|
||||
if((k->keepon & KEEP_SEND) && (select_bits & CURL_CSELECT_OUT)) {
|
||||
/* write */
|
||||
|
||||
result = readwrite_upload(data, conn, &didwhat);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue