curl-library
aborting curl_easy_perform()
Date: Mon, 22 Aug 2005 09:39:08 +1000
I have the need to abort a curl_easy_perform() instantly, or close to 
it, at any time during it's operation, whether connecting, transferring, 
or waiting for a timeout.
I have seen this a lot on the mailing list, and as far as I know this is 
still not an available feature.  Is this true?
 From what I have read, the suggestion has been to return an error from 
within a callback.  However, there are times (such as waiting for a 
connection) when no callback is called.  This is, I believe, a fairly 
typical situation.  I have a multi-threaded program, and one of the 
threads is initiating or executing a transfer.  Other threads, oblivious 
to this, may be operating a control panel or some other UI component 
which, at the user's whim, may be clicked and cause the chosen transfer 
to immediately terminate.  I can't have the user "waiting" for this.  It 
needs to be instant.
I am going to implement some method of doing this and send a patch.  
However, I wanted to be SURE that nobody else is implementing the same 
thing, or that there is no better way before I spend the time doing so.
My method will be to create a new curl_easy_setopt called 
CURLOPT_ABORTFLAG, which is called like this:
    volatile long abort_flag = 0;
    curl_easy_setopt(curlhandle, CURLOPT_ABORTFLAG, (long)&abort_flag);
At any time, any asynchronous thread can set abort flag to 1 in order to 
cause CURL to abort the current operation.
Is this reasonable?
-G
Received on 2005-08-22