A libcurl in my php code seems to be stuck indefinitely in a poll
call. When I did an strace to the process id,
[user@server ~]$ sudo strace -p 19559
Process 19559 attached - interrupt to quit
poll([{fd=7, events=POLLIN}], 1, 1000) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 0) = 0 (Timeout)
poll([{fd=7, events=POLLIN}], 1, 1000) = 0 (Timeout)
This goes on indefinitely. The fd 7 is shown in /proc/19559/fd as
lrwx------ 1 root root 64 Sep 19 19:44 7 -> socket:[335178801]
Can someone tell me why this is happening. What can I do to make libcurl exit when it timesout
Further, most operations in curl have no time-out by default! Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data.
Tell curl with -m / --max-time the maximum time, in seconds, that you allow the command line to spend before curl exits with a timeout error code (28). When the set time has elapsed, curl will exit no matter what is going on at that moment—including if it is transferring data. It really is the maximum time allowed.
As an alternative to a fixed time-out, you can tell curl to abandon the transfer if it gets below a certain speed and stays below that threshold for a specific period of time. For example, if a transfer speed goes below 1000 bytes per second during 15 seconds, stop it: curl enables TCP keep-alive by default.
Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when converted to milliseconds is too large.
curl_setopt
option CURLOPT_CONNECTTIMEOUT
if set to nonzero value will render curl to fail on timeout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With