cURL / Mailing Lists / curl-library / Single Mail

curl-library

Setting options when transfer in progress

From: Colin Hogben <curl_at_pythontech.co.uk>
Date: Sat, 28 Jun 2014 21:39:20 +0100

Hi,
I found that some of the code that I wrote a long while ago was doing

   curl_easy_setopt(easy, CURLOPT_TIMEOUT, timeout)

from within CURLOPT_HEADERFUNCTION and CURLOPT_WRITEFUNCTION callbacks.
  The idea was to implement a sliding window such that the transfer
would fail if the server didn't send any data for a time.
Now, I don't know whether I omitted to test this intended behaviour, or
whether libcurl's treatment of timeouts has changed in the meantime, but
I find that it does not now work as I had intended. I am using the
multi socket framework; my timer event calls curl_multi_socket_action
with CURL_SOCKET_TIMEOUT, but libcurl keeps the transfer going.

I'm not too worried about trying to make libcurl do what I intended in
this case - I can apply my own timeout externally.

However, it does raise the issue of which API calls are valid in which
contexts, expecially from with callback functions registered with
libcurl. Perhaps the manual pages could be updated with this advice,
e.g. something like:

"Note that curl_easy_setopt may only validly be called before starting a
transfer; calling this function during a transfer, e.g. from a callback
from libcurl, is not supported and may have unpredictable results."

What do people think?

-- 
Colin Hogben
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-06-28