Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ephiperfifo.c example #5485

Closed
therealhirudo opened this issue May 29, 2020 · 2 comments
Closed

ephiperfifo.c example #5485

therealhirudo opened this issue May 29, 2020 · 2 comments

Comments

@therealhirudo
Copy link

therealhirudo commented May 29, 2020

I did this

Ran the example, passed URL to the fifo

I expected the following

Whenever the last transfer finishes, I'd expect to see
"last transfer done, kill timeout"
and the mainloop waits for the next fifo call, without timer events

What I saw

Sometimes the message above is missing, and the mainloop keeps calling the timer after the last transfer is done.

curl/libcurl version

curl 7.66.0 (x86_64-redhat-linux-gnu) libcurl/7.66.0 OpenSSL/1.1.1d-fips zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.0/openssl/zlib nghttp2/1.39.2
Release-Date: 2019-09-11
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

operating system

Linux fc31 5.3.7-301.fc31.x86_64 #1 SMP Mon Oct 21 19:18:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Extra info:

In the good case, the end of the sequence is generally:
REMAINING: 1
Progress: http://www.example.com (62/62)
socket callback: s=6 e=0x54a1e20 what=REMOVE
multi_timer_cb: Setting timeout to -1 ms
REMAINING: 0
DONE: http://www.example.com => (0)
last transfer done, kill timeout

In the "bad" case, it's:
REMAINING: 1
socket callback: s=6 e=0x5482b60 what=REMOVE
Progress: http://www.example.com (62/62)
REMAINING: 0
DONE: http://www.leahnim.org => (0)
REMAINING: 0
REMAINING: 0
...

Call chain in the good case seems to be:
curl_multi_socket_action(real socket)-> { write_callback ; socket_callback remove action } -> timer_callback -1

In the bad case:
curl_multi_socket_action(TIMEOUT) -> {write_callback ; socket_callback remove action }

i.e. the timer callback isn't called.

@Billyzou0741326
Copy link
Contributor

I was able to reproduce the output by triggering a bad case (i.e. passing in an unresolvable hostname).

Looking further into the ephiperfifo source code, it appears that, unless timeout_ms give by curl is -1, the timerfd is configured to an interval of 1 second regardless of the value of the initial timeout. That is, it makes use a repeating timer.

In real world scenarios, the documentation suggests CURLMOPT_TIMER_FUNCTION setting a non-repeating timer, so that the timer will not be triggered repeatedly when bad cases arise (where there's no need to reset a timer).

I ended up turning these interval settings to 0:

its.it_interval.tv_sec = 1;

its.it_interval.tv_sec = 1;

its.it_interval.tv_sec = 1;

@bagder
Copy link
Member

bagder commented Jun 1, 2020

@Billyzou0741326 would you mind submitting these fixes as a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants