From: Alexander Couzens Date: Mon, 4 Dec 2017 14:41:20 +0000 (+0100) Subject: add opkg option http_timeout X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ebdfc128a7bc527c1c960eef6105b1ff91e48bdc;p=oweals%2Fopkg-lede.git add opkg option http_timeout http_timeout will append `--timeout xy` to the resulting wget call. This is useful when using opkg update in a automatic way and prevent long timeouts Signed-off-by: Alexander Couzens --- diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c index bab8f57..08855eb 100644 --- a/libopkg/opkg_conf.c +++ b/libopkg/opkg_conf.c @@ -57,6 +57,7 @@ opkg_option_t options[] = { {"no_check_certificate", OPKG_OPT_TYPE_BOOL, &_conf.no_check_certificate}, {"ftp_proxy", OPKG_OPT_TYPE_STRING, &_conf.ftp_proxy}, {"http_proxy", OPKG_OPT_TYPE_STRING, &_conf.http_proxy}, + {"http_timeout", OPKG_OPT_TYPE_STRING, &_conf.http_timeout}, {"no_proxy", OPKG_OPT_TYPE_STRING, &_conf.no_proxy}, {"test", OPKG_OPT_TYPE_BOOL, &_conf.noaction}, {"noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction}, diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h index b63a1e6..37f95a1 100644 --- a/libopkg/opkg_conf.h +++ b/libopkg/opkg_conf.h @@ -92,6 +92,7 @@ struct opkg_conf { /* proxy options */ char *http_proxy; + char *http_timeout; char *ftp_proxy; char *no_proxy; char *proxy_user; diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index e57d053..8acbc66 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -87,7 +87,7 @@ opkg_download(const char *src, const char *dest_file_name, { int res; - const char *argv[9]; + const char *argv[11]; int i = 0; argv[i++] = "wget"; @@ -95,6 +95,10 @@ opkg_download(const char *src, const char *dest_file_name, if (conf->no_check_certificate) { argv[i++] = "--no-check-certificate"; } + if (conf->http_timeout) { + argv[i++] = "--timeout"; + argv[i++] = conf->http_timeout; + } if (conf->http_proxy || conf->ftp_proxy) { argv[i++] = "-Y"; argv[i++] = "on";