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:
Stefan Eissing 2023-04-21 12:04:46 +02:00 committed by Daniel Stenberg
parent a97e4eb95f
commit cab2d56ea5
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 152 additions and 170 deletions

View file

@ -1319,6 +1319,8 @@ struct UrlState {
char *scratch; /* huge buffer[set.buffer_size*2] for upload CRLF replacing */
long followlocation; /* redirect counter */
int requests; /* request counter: redirects + authentication retakes */
int dselect_bits; /* != 0 -> bitmask of socket events for this transfer
* overriding anything the socket may report */
#ifdef HAVE_SIGNAL
/* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
void (*prev_signal)(int sig);
@ -1374,9 +1376,6 @@ struct UrlState {
curl_off_t infilesize; /* size of file to upload, -1 means unknown.
Copied from set.filesize at start of operation */
#if defined(USE_HTTP2) || defined(USE_HTTP3)
size_t drain; /* Increased when this stream has data to read, even if its
socket is not necessarily is readable. Decreased when
checked. */
struct Curl_data_priority priority; /* shallow copy of data->set */
#endif