Re: how to stop curl_easy_perform()
Date: Thu, 13 Sep 2007 15:54:15 +0200 (CEST)
On Thu, 13 Sep 2007, Dragos MOINESCU wrote:
(Please don't reply to an existing mail as a shortcut to start a new thread.
Modern mail clients and the web archives etc all use threading information
that the mails contain, so your mail here ends up as a reply in a thread to
which this mail doesn't really belong...)
> I have a problem in stoping a curl_easy_perform() from another thread.
You can't do that directly. You should set a variable or a sepaphore or
similar, and then have the thread using libcurl abort the transfer when it
> I tried to curl_easy_cleanup() that handle but got SIGSEGV (which in my
> opinion is normal behavior).
You must never ever without conditions use the same easy handle in more than
> My question is how to handle the following
> situation: 1. $ nc -l -p 8080 2. $ ./test-curl localhost:8080
> The client connects to localhost:8080 and sends the request but the server
> doesn't respond with no data. The problem is that I need to kill ./test-curl
> application with a SIGINT and it MUST exit nicely (to free every resources).
> Is there a possibility to close the socket(s) the handler uses?
Just killing a process will of course close the sockets fine.
> I understand that curl_easy cannot be used to simultaneous download
> resources from different http sites although it might have more connections
> opened. Thus it "knows" the active socket it handles. So, I believe there
> might be a function called curl_easy_stop() which can be called from another
> thread in order to stop curl_easy_perform(). Although this function may
> appear in the future, I need an elegant solution for now.
libcurl offers serveral timeout options and several callback functions. All
callback functions, including the progress callback, have the ability to stop
the transfer. I would suggest you make them check for some condition that you
can trigger from another thread, and when that has happened the callback(s)
return the appropriate error code.
-- Commercial curl and libcurl Technical Support: http://haxx.se/curl.htmlReceived on 2007-09-13