multi: xfers_really_alive

Yes, we were counting the "live" transfers before, but were they
*really* alive?

When determining to add the wakeup socket to fdset/waitfds etc, we
should only do that when the multi handle is actually processing
transfers. Other wise, the application could wait on the wakeup socket
forever.

For this, we counted `multi->xfers_alive` (e.g. the "running" number
returned by `curl_multi_perform()`). This was almost correct.

The problem is that added easy handles are counted as "alive" right away
on the addition. But the processing has not started yet. They did not
trigger any DNS resolves or opened any sockets yet.

Add two fields in multi and easy handle:

* `multi->xfers_really_alive`: counts the "alive" transfers that have
  passed `MSTATE_INIT` (at least once)
* `data->state.really_alive`: to track if the transfer has been counted

Add test 2412 to check that adding transfers without perform will not
trigger the wakeup socket to be added.

Fixes #22050
Reported-by: Bryan Henderson
Closes #22066
This commit is contained in:
Stefan Eissing 2026-06-17 14:20:02 +02:00 committed by Daniel Stenberg
parent abad1c9e48
commit f0be417635
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 182 additions and 13 deletions

View file

@ -262,7 +262,7 @@ test2300 test2301 test2302 test2303 test2304 test2306 test2307 test2308 \
test2309 test2310 test2311 \
\
test2400 test2401 test2402 test2403 test2404 test2405 test2406 test2407 \
test2408 test2409 test2410 test2411 \
test2408 test2409 test2410 test2411 test2412 \
\
test2500 test2501 test2502 test2503 test2504 test2505 test2506 \
\

50
tests/data/test2412 Normal file
View file

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="US-ASCII"?>
<testcase>
<info>
<keywords>
multi
</keywords>
</info>
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498"
Accept-Ranges: bytes
Content-Length: 6007
Connection: close
Content-Type: text/html
Funny-head: yesyes
-foo-
%repeat[1000 x foobar]%
</data>
</reply>
# Client-side
<client>
<features>
wakeup
</features>
<server>
http
</server>
<tool>
lib%TESTNUMBER
</tool>
<name>
checking curl_multi_fdset on nothing to do
</name>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
# Verify data after the test has been "shot"
<verify>
</verify>
</testcase>