mirror of
https://github.com/strongswan/strongswan.git
synced 2025-12-08 00:00:29 -05:00
Use CURL_TIMEOUT and not CURL_CONNECTTIMEOUT for FETCHER_TIMEOUT in curl
This allows us to use this timeout beyond DNS resolution. For the initial connect, we use a hardcoded timeout of 10s for now.
This commit is contained in:
parent
2ccdc19ed9
commit
763e86c093
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "curl_fetcher.h"
|
#include "curl_fetcher.h"
|
||||||
|
|
||||||
#define DEFAULT_TIMEOUT 10
|
#define CONNECT_TIMEOUT 10
|
||||||
|
|
||||||
typedef struct private_curl_fetcher_t private_curl_fetcher_t;
|
typedef struct private_curl_fetcher_t private_curl_fetcher_t;
|
||||||
|
|
||||||
@ -48,6 +48,11 @@ struct private_curl_fetcher_t {
|
|||||||
* Callback function
|
* Callback function
|
||||||
*/
|
*/
|
||||||
fetcher_callback_t cb;
|
fetcher_callback_t cb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timeout for a transfer
|
||||||
|
*/
|
||||||
|
long timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +99,11 @@ METHOD(fetcher_t, fetch, status_t,
|
|||||||
curl_easy_setopt(this->curl, CURLOPT_ERRORBUFFER, error);
|
curl_easy_setopt(this->curl, CURLOPT_ERRORBUFFER, error);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, TRUE);
|
curl_easy_setopt(this->curl, CURLOPT_FAILONERROR, TRUE);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_NOSIGNAL, TRUE);
|
curl_easy_setopt(this->curl, CURLOPT_NOSIGNAL, TRUE);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT, DEFAULT_TIMEOUT);
|
if (this->timeout)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(this->curl, CURLOPT_TIMEOUT, this->timeout);
|
||||||
|
}
|
||||||
|
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT, CONNECT_TIMEOUT);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, (void*)curl_cb);
|
curl_easy_setopt(this->curl, CURLOPT_WRITEFUNCTION, (void*)curl_cb);
|
||||||
curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, &data);
|
curl_easy_setopt(this->curl, CURLOPT_WRITEDATA, &data);
|
||||||
if (this->headers)
|
if (this->headers)
|
||||||
@ -160,8 +169,7 @@ METHOD(fetcher_t, set_option, bool,
|
|||||||
}
|
}
|
||||||
case FETCH_TIMEOUT:
|
case FETCH_TIMEOUT:
|
||||||
{
|
{
|
||||||
curl_easy_setopt(this->curl, CURLOPT_CONNECTTIMEOUT,
|
this->timeout = va_arg(args, u_int);
|
||||||
va_arg(args, u_int));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FETCH_CALLBACK:
|
case FETCH_CALLBACK:
|
||||||
@ -211,4 +219,3 @@ curl_fetcher_t *curl_fetcher_create()
|
|||||||
}
|
}
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user