Skip to content

fixed callback for CURLMOPT_TIMERFUNCTION not being called again when…#15627

Closed
sokurenko wants to merge 3 commits intocurl:masterfrom
sokurenko:curl-async
Closed

fixed callback for CURLMOPT_TIMERFUNCTION not being called again when…#15627
sokurenko wants to merge 3 commits intocurl:masterfrom
sokurenko:curl-async

Conversation

@sokurenko
Copy link
Copy Markdown
Contributor

@sokurenko sokurenko commented Nov 22, 2024

Issue is reproducible for me if I have made request with multi handle, then I make request that will take very long and then I make request that should be fast again, however what happens it is that it seems to think that timeout was not changed and it makes it not call initial CURLMOPT_TIMERFUNCTION

Log:
508228:20241122:172515.743 In zbx_http_request_prepare() request method 'GET' URL 'localhost:8080/hello' headers ''
508228:20241122:172515.761 End of zbx_http_request_prepare():SUCCEED
expire timestamps:0.0 -> 20372.68080 now:20372.71430 timeout_ms:0
Curl_update_timer(), had no timeout, set now
Curl_update_timer(), set timeout 0ms
508228:20241122:172515.771 start_timeout() timeout:0
508228:20241122:172515.773 In zbx_http_request_prepare() request method 'GET' URL 'localhost:8080/timeout' headers ''
508228:20241122:172515.774 End of zbx_http_request_prepare():SUCCEED
expire timestamps:20372.68080 -> 20372.68080 now:20372.80296 timeout_ms:0
Curl_update_timer(), same expire timestamp, no change
508228:20241122:172515.781 End of async_initiate_queued_checks(): num:2
508228:20241122:172515.782 In on_timeout()
508228:20241122:172515.880 In handle_socket() action:2
508228:20241122:172515.882 End of handle_socket()
508228:20241122:172515.889 In handle_socket() action:2
508228:20241122:172515.889 End of handle_socket()
expire timestamps:20372.68080 -> 20372.347305 now:20372.195431 timeout_ms:153
Curl_update_timer(), expire timestamp changed
Curl_update_timer(), set timeout 153ms
508228:20241122:172515.891 start_timeout() timeout:153
508228:20241122:172515.892 End of on_timeout()
508228:20241122:172515.893 In curl_perform()
508228:20241122:172515.959 In handle_socket() action:4
508228:20241122:172515.960 End of handle_socket()
expire timestamps:20372.347305 -> 20372.390129 now:20372.266304 timeout_ms:124
Curl_update_timer(), expire timestamp changed
Curl_update_timer(), set timeout 124ms
508228:20241122:172515.962 start_timeout() timeout:124
508228:20241122:172515.962 running_handles:1
508228:20241122:172515.963 pending cURL messages:0
508228:20241122:172515.964 In process_httpagent_result()
508228:20241122:172515.972 name 'Content-Type' value 'text/plain; charset=utf-8' amount:1 index:0 origin:134217729
508228:20241122:172515.985 finished processing itemid:48298
508228:20241122:172515.995 End of process_httpagent_result()
508228:20241122:172515.995 End of curl_perform()
508228:20241122:172515.995 In curl_perform()
508228:20241122:172515.999 In handle_socket() action:1
508228:20241122:172515.999 End of handle_socket()
expire timestamps:20372.390129 -> 20372.390129 now:20372.304592 timeout_ms:86
Curl_update_timer(), same expire timestamp, no change
508228:20241122:172516.000 running_handles:1
508228:20241122:172516.000 End of curl_perform()
508228:20241122:172516.001 In zbx_ipc_socket_open()
508228:20241122:172516.001 End of zbx_ipc_socket_open():SUCCEED
508228:20241122:172516.002 In zbx_ipc_socket_write()
508228:20241122:172516.003 End of zbx_ipc_socket_write():SUCCEED
508228:20241122:172516.004 requeue num:1
508228:20241122:172516.016 requeue items nextcheck:1732289158
508228:20241122:172516.019 In on_timeout()
expire timestamps:20372.390129 -> 20372.390129 now:20372.324148 timeout_ms:66
Curl_update_timer(), same expire timestamp, no change
508228:20241122:172516.020 End of on_timeout()
508228:20241122:172516.679 In zbx_dc_config_get_poller_items() poller_type:7
508228:20241122:172535.692 End of zbx_prepare_items()
508228:20241122:172535.692 queue processing_num:1 pending:0
508228:20241122:172535.693 In async_initiate_queued_checks()
508228:20241122:172535.693 In zbx_http_request_prepare() request method 'GET' URL 'localhost:8080/hello' headers ''
508228:20241122:172535.693 End of zbx_http_request_prepare():SUCCEED
expire timestamps:20372.390129 -> 20372.390129 now:20391.998933 timeout_ms:0
Curl_update_timer(), same expire timestamp, no change

@icing icing self-requested a review November 22, 2024 15:19
Copy link
Copy Markdown
Contributor

@icing icing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find!

@MarcelRaad
Copy link
Copy Markdown
Member

I was just debugging a hang when using an invalid URL with the multi_socket API after a58b50f and I can confirm that this fixes it! Thanks!

@vszakats vszakats closed this in 4cded6d Nov 25, 2024
@vszakats
Copy link
Copy Markdown
Member

Thank you! This is merged now.

pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
…in when...

Issue is reproducible for me if I have made request with multi handle,
then I make request that will take very long and then I make request
that should be fast again, however what happens it is that it seems
to think that timeout was not changed and it makes it not call initial
`CURLMOPT_TIMERFUNCTION`.

Closes curl#15627
refi64 added a commit to refi64/packages that referenced this pull request Jun 7, 2025
Curl 8.10.x and 8.11.0 have a bug where, when using the multi interface,
timer callbacks might not always be invoked properly:

curl/curl#15627

In particular, on my setup, this results in https-dns-proxy being unable
to time out a hanging HTTP/2 connection, which in turn causes all future
multiplexed requests to also get stuck in `MSTATE_INIT`. 8.11.1 got the
aforementioned fix, but it never made it into the 8.10.x line, so
OpenWRT is still affected.

Signed-off-by: re:fi.64 <[email protected]>
refi64 added a commit to refi64/packages that referenced this pull request Jun 7, 2025
Curl 8.10.x and 8.11.0 have a bug where, when using the multi interface,
timer callbacks might not always be invoked properly:

curl/curl#15627

In particular, on my setup, this results in https-dns-proxy being unable
to time out a hanging HTTP/2 connection, which in turn causes all future
multiplexed requests to also get stuck in `MSTATE_INIT`. 8.11.1 got the
aforementioned fix, but it never made it into the 8.10.x line, so
OpenWRT is still affected.

Signed-off-by: re:fi.64 <[email protected]>
refi64 added a commit to refi64/packages that referenced this pull request Jun 7, 2025
Curl 8.10.x and 8.11.0 have a bug where, when using the multi interface,
timer callbacks might not always be invoked properly:

curl/curl#15627

In particular, on my setup, this results in https-dns-proxy being unable
to time out a hanging HTTP/2 connection, which in turn causes all future
multiplexed requests to also get stuck in `MSTATE_INIT`. 8.11.1 got the
aforementioned fix, but it never made it into the 8.10.x line, so
OpenWRT is still affected.

Signed-off-by: Ryan Gonzalez <[email protected]>
refi64 added a commit to refi64/packages that referenced this pull request Jun 7, 2025
Curl 8.10.x and 8.11.0 have a bug where, when using the multi interface,
timer callbacks might not always be invoked properly:

curl/curl#15627

In particular, on my setup, this results in https-dns-proxy being unable
to time out a hanging HTTP/2 connection, which in turn causes all future
multiplexed requests to also get stuck in `MSTATE_INIT`. 8.11.1 got the
aforementioned fix, but it never made it into the 8.10.x line, so
OpenWRT is still affected.

Signed-off-by: Ryan Gonzalez <[email protected]>
EdmondDantes added a commit to true-async/php-src that referenced this pull request Mar 2, 2026
libcurl < 8.11.1 has multiple bugs in the PAUSE/unpause mechanism
(tempcount guard on cselect_bits, timer_lastcall optimization issues)
that cause intermittent hangs during async file uploads (~20% failure).

For curl < 8.11.1: use synchronous read() in the read callback,
avoiding PAUSE entirely. For curl >= 8.11.1: use the async
PAUSE/unpause pattern which works reliably after upstream fixes.

Also extract curl_async_unpause_transfer() helper used by all three
unpause sites (file read, file write, user write callbacks).

See: curl/curl#15627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants