connection: attached transfer count

Since we no longer traverse the transfers attached to a connection,
change the sparse bitset to just a `uint32_t` counter.

This makes multi_ev the single user of sparse bitsets for transfers
using a socket and allocation failures are handled there correctly.

Refs #19818
Closes #19836
This commit is contained in:
Stefan Eissing 2025-12-04 17:15:33 +01:00 committed by Daniel Stenberg
parent 1def380032
commit d7928029fc
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 29 additions and 44 deletions

View file

@ -607,12 +607,11 @@ static void multi_done_locked(struct connectdata *conn,
Curl_detach_connection(data);
CURL_TRC_M(data, "multi_done_locked, in use=%u",
Curl_uint32_spbset_count(&conn->xfers_attached));
CURL_TRC_M(data, "multi_done_locked, in use=%u", conn->attached_xfers);
if(CONN_INUSE(conn)) {
/* Stop if still used. */
CURL_TRC_M(data, "Connection still in use %u, no more multi_done now!",
Curl_uint32_spbset_count(&conn->xfers_attached));
conn->attached_xfers);
return;
}
@ -906,9 +905,13 @@ void Curl_detach_connection(struct Curl_easy *data)
{
struct connectdata *conn = data->conn;
if(conn) {
Curl_uint32_spbset_remove(&conn->xfers_attached, data->mid);
if(Curl_uint32_spbset_empty(&conn->xfers_attached))
conn->attached_multi = NULL;
/* this should never happen, prevent underflow */
DEBUGASSERT(conn->attached_xfers);
if(conn->attached_xfers) {
conn->attached_xfers--;
if(!conn->attached_xfers)
conn->attached_multi = NULL;
}
}
data->conn = NULL;
}
@ -924,8 +927,9 @@ void Curl_attach_connection(struct Curl_easy *data,
DEBUGASSERT(data);
DEBUGASSERT(!data->conn);
DEBUGASSERT(conn);
DEBUGASSERT(conn->attached_xfers < UINT32_MAX);
data->conn = conn;
Curl_uint32_spbset_add(&conn->xfers_attached, data->mid);
conn->attached_xfers++;
/* all attached transfers must be from the same multi */
if(!conn->attached_multi)
conn->attached_multi = data->multi;