curl-library
curl_easy_perform + interrupt
Date: Sat, 6 Feb 2016 20:07:48 +0100
The R programming language exposes a C function pending_interrupt()
which we can use to check if the user has sent a SIGINT in the GUI.
For the R libcurl bindings, we use curl_easy_perform() and check for
such interrupts within CURLOPT_WRITEFUNCTION, CURLOPT_READFUNCTION and
CURLOPT_PROGRESSFUNCTION, e.g:
if(pending_interrupt()){
return CURL_READFUNC_ABORT;
}
However users have complained that this mechanism doesn't always work
well. For example if the server stalls during the initial connecting
phase or ssl handshake, none of the callback functions is triggered
and SIGINT gets ignored. This causes the GUI to freeze until timeout.
I am now exploring a different approach: I implemented a new function
curl_perform_with_interrupt() which is a drop-in replacement of
curl_easy_perform() however with checking for interrupts. My first
pass is here: https://github.com/jeroenooms/curl/blob/interrupt/src/utils.c#L127-L999
This seems to work but it looks ugly and I am not confident that this
covers all edge cases. I was wondering if there is a more elegant
method, or existing examples of how to implement something like
curl_easy_perform() while reliably catching interruptions at any stage
of the connection?
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-02-06