lib: replace getsock() logic with pollsets

`getsock()` calls operated on a global limit that could
not be configure beyond 16 sockets. This is no longer adequate
with the new happy eyeballing strategy.

Instead, do the following:
- make `struct easy_pollset` dynamic. Starting with
  a minimal room for two sockets, the very common case,
  allow it to grow on demand.
- replace all protocol handler getsock() calls with pollsets
  and a CURLcode to return failures
- add CURLcode return for all connection filter `adjust_pollset()`
  callbacks, since they too can now fail.
- use appropriately in multi.c and multi_ev.c
- fix unit2600 to trigger pollset growth

Closes #18164
This commit is contained in:
Stefan Eissing 2025-08-04 16:17:37 +02:00 committed by Daniel Stenberg
parent c85c2b7be7
commit 5b80b4c012
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
54 changed files with 1002 additions and 873 deletions

View file

@ -35,6 +35,7 @@
#include "multiif.h"
#include "cf-https-connect.h"
#include "http2.h"
#include "select.h"
#include "vquic/vquic.h"
/* The last 3 #include files should be in this order */
@ -426,22 +427,24 @@ static CURLcode cf_hc_shutdown(struct Curl_cfilter *cf,
return result;
}
static void cf_hc_adjust_pollset(struct Curl_cfilter *cf,
struct Curl_easy *data,
struct easy_pollset *ps)
static CURLcode cf_hc_adjust_pollset(struct Curl_cfilter *cf,
struct Curl_easy *data,
struct easy_pollset *ps)
{
CURLcode result = CURLE_OK;
if(!cf->connected) {
struct cf_hc_ctx *ctx = cf->ctx;
size_t i;
for(i = 0; i < ctx->baller_count; i++) {
for(i = 0; (i < ctx->baller_count) && !result; i++) {
struct cf_hc_baller *b = &ctx->ballers[i];
if(!cf_hc_baller_is_active(b))
continue;
Curl_conn_cf_adjust_pollset(b->cf, data, ps);
result = Curl_conn_cf_adjust_pollset(b->cf, data, ps);
}
CURL_TRC_CF(data, cf, "adjust_pollset -> %d socks", ps->num);
CURL_TRC_CF(data, cf, "adjust_pollset -> %d, %d socks", result, ps->n);
}
return result;
}
static bool cf_hc_data_pending(struct Curl_cfilter *cf,