mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Markus F.X.J. Oberhumer's CURLOPT_NOSIGNAL patch
This commit is contained in:
parent
ca5678c8c1
commit
4cf953678d
@ -562,6 +562,9 @@ typedef enum {
|
|||||||
/* Instruct libcurl to use a smaller receive buffer */
|
/* Instruct libcurl to use a smaller receive buffer */
|
||||||
CINIT(BUFFERSIZE, LONG, 98),
|
CINIT(BUFFERSIZE, LONG, 98),
|
||||||
|
|
||||||
|
/* Instruct libcurl to do not use any signal/alarm handlers, even with timeouts. */
|
||||||
|
CINIT(NOSIGNAL, LONG, 99),
|
||||||
|
|
||||||
CURLOPT_LASTENTRY /* the last unusued */
|
CURLOPT_LASTENTRY /* the last unusued */
|
||||||
} CURLoption;
|
} CURLoption;
|
||||||
|
|
||||||
|
@ -1130,6 +1130,7 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
|
|||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Tell signal handler to ignore SIGPIPE
|
* Tell signal handler to ignore SIGPIPE
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
|
if(!data->set.no_signal)
|
||||||
data->state.prev_signal = signal(SIGPIPE, SIG_IGN);
|
data->state.prev_signal = signal(SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1143,6 +1144,7 @@ CURLcode Curl_posttransfer(struct SessionHandle *data)
|
|||||||
{
|
{
|
||||||
#if defined(HAVE_SIGNAL) && defined(SIGPIPE)
|
#if defined(HAVE_SIGNAL) && defined(SIGPIPE)
|
||||||
/* restore the signal handler for SIGPIPE before we get back */
|
/* restore the signal handler for SIGPIPE before we get back */
|
||||||
|
if(!data->set.no_signal)
|
||||||
signal(SIGPIPE, data->state.prev_signal);
|
signal(SIGPIPE, data->state.prev_signal);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
12
lib/url.c
12
lib/url.c
@ -1024,6 +1024,14 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CURLOPT_NOSIGNAL:
|
||||||
|
/*
|
||||||
|
* The application asks not to set any signal() or alarm() handlers,
|
||||||
|
* even when using a timeout.
|
||||||
|
*/
|
||||||
|
data->set.no_signal = va_arg(param, long) ? TRUE : FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* unknown tag and its companion, just ignore: */
|
/* unknown tag and its companion, just ignore: */
|
||||||
return CURLE_FAILED_INIT; /* correct this */
|
return CURLE_FAILED_INIT; /* correct this */
|
||||||
@ -2281,7 +2289,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Set timeout if that is being used
|
* Set timeout if that is being used
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
if(data->set.timeout || data->set.connecttimeout) {
|
if((data->set.timeout || data->set.connecttimeout) && !data->set.no_signal) {
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Set signal handler to catch SIGALRM
|
* Set signal handler to catch SIGALRM
|
||||||
* Store the old value to be able to set it back later!
|
* Store the old value to be able to set it back later!
|
||||||
@ -2358,7 +2366,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
|
|||||||
}
|
}
|
||||||
Curl_pgrsTime(data, TIMER_NAMELOOKUP);
|
Curl_pgrsTime(data, TIMER_NAMELOOKUP);
|
||||||
#ifdef HAVE_ALARM
|
#ifdef HAVE_ALARM
|
||||||
if(data->set.timeout || data->set.connecttimeout) {
|
if((data->set.timeout || data->set.connecttimeout) && !data->set.no_signal) {
|
||||||
#ifdef HAVE_SIGACTION
|
#ifdef HAVE_SIGACTION
|
||||||
if(keep_copysig) {
|
if(keep_copysig) {
|
||||||
/* we got a struct as it looked before, now put that one back nice
|
/* we got a struct as it looked before, now put that one back nice
|
||||||
|
@ -668,6 +668,7 @@ struct UserDefined {
|
|||||||
bool reuse_fresh; /* do not re-use an existing connection */
|
bool reuse_fresh; /* do not re-use an existing connection */
|
||||||
bool expect100header; /* TRUE if we added Expect: 100-continue */
|
bool expect100header; /* TRUE if we added Expect: 100-continue */
|
||||||
bool ftp_use_epsv; /* if EPSV is to be attempted or not */
|
bool ftp_use_epsv; /* if EPSV is to be attempted or not */
|
||||||
|
bool no_signal;
|
||||||
|
|
||||||
bool global_dns_cache;
|
bool global_dns_cache;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user