Message ID | 20180305154006.18122-3-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/8] channel_curl: add support for Basic Auth credentials | expand |
On 05/03/2018 16:40, Christian Storm wrote: > downloader.c has a command line flag '--timeout' setting > cURL's low speed limit time period. Make this setting > configurable for channel_curl in preparation to make the > downloader use channel_curl. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > corelib/channel_curl.c | 8 +++++++- > include/channel_curl.h | 1 + > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c > index a94243d..ea23f61 100644 > --- a/corelib/channel_curl.c > +++ b/corelib/channel_curl.c > @@ -331,6 +331,12 @@ channel_op_res_t channel_set_options(channel_t *this, > channel_data_t *channel_data, > channel_method_t method) > { > + if (channel_data->low_speed_timeout == 0) { > + channel_data->low_speed_timeout = SPEED_LOW_TIME_SEC; > + DEBUG("cURL's low download speed timeout is disabled, " > + "this is most probably not what you want. " > + "Adapted it to %us instead.\n", SPEED_LOW_TIME_SEC); > + } > channel_curl_t *channel_curl = this->priv; > channel_op_res_t result = CHANNEL_OK; > if ((curl_easy_setopt(channel_curl->handle, CURLOPT_URL, > @@ -340,7 +346,7 @@ channel_op_res_t channel_set_options(channel_t *this, > (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_LIMIT, > SPEED_LOW_BYTES_SEC) != CURLE_OK) || > (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_TIME, > - SPEED_LOW_TIME_SEC) != CURLE_OK) || > + channel_data->low_speed_timeout) != CURLE_OK) || > (curl_easy_setopt(channel_curl->handle, CURLOPT_HTTPHEADER, > channel_curl->header) != CURLE_OK) || > (curl_easy_setopt(channel_curl->handle, CURLOPT_MAXREDIRS, -1) != > diff --git a/include/channel_curl.h b/include/channel_curl.h > index 5afb66f..eec071e 100644 > --- a/include/channel_curl.h > +++ b/include/channel_curl.h > @@ -43,6 +43,7 @@ typedef struct { > unsigned int offs; > unsigned int method; > unsigned int retries; > + unsigned int low_speed_timeout; > bool debug; > bool usessl; > bool strictssl; > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index a94243d..ea23f61 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -331,6 +331,12 @@ channel_op_res_t channel_set_options(channel_t *this, channel_data_t *channel_data, channel_method_t method) { + if (channel_data->low_speed_timeout == 0) { + channel_data->low_speed_timeout = SPEED_LOW_TIME_SEC; + DEBUG("cURL's low download speed timeout is disabled, " + "this is most probably not what you want. " + "Adapted it to %us instead.\n", SPEED_LOW_TIME_SEC); + } channel_curl_t *channel_curl = this->priv; channel_op_res_t result = CHANNEL_OK; if ((curl_easy_setopt(channel_curl->handle, CURLOPT_URL, @@ -340,7 +346,7 @@ channel_op_res_t channel_set_options(channel_t *this, (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_LIMIT, SPEED_LOW_BYTES_SEC) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_LOW_SPEED_TIME, - SPEED_LOW_TIME_SEC) != CURLE_OK) || + channel_data->low_speed_timeout) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_HTTPHEADER, channel_curl->header) != CURLE_OK) || (curl_easy_setopt(channel_curl->handle, CURLOPT_MAXREDIRS, -1) != diff --git a/include/channel_curl.h b/include/channel_curl.h index 5afb66f..eec071e 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -43,6 +43,7 @@ typedef struct { unsigned int offs; unsigned int method; unsigned int retries; + unsigned int low_speed_timeout; bool debug; bool usessl; bool strictssl;
downloader.c has a command line flag '--timeout' setting cURL's low speed limit time period. Make this setting configurable for channel_curl in preparation to make the downloader use channel_curl. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- corelib/channel_curl.c | 8 +++++++- include/channel_curl.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)