add opkg option http_timeout
authorAlexander Couzens <lynxis@fe80.eu>
Mon, 4 Dec 2017 14:41:20 +0000 (15:41 +0100)
committerAlexander Couzens <lynxis@fe80.eu>
Thu, 7 Dec 2017 12:32:20 +0000 (13:32 +0100)
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 <lynxis@fe80.eu>
libopkg/opkg_conf.c
libopkg/opkg_conf.h
libopkg/opkg_download.c

index bab8f57..08855eb 100644 (file)
@@ -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},
index b63a1e6..37f95a1 100644 (file)
@@ -92,6 +92,7 @@ struct opkg_conf {
 
        /* proxy options */
        char *http_proxy;
+       char *http_timeout;
        char *ftp_proxy;
        char *no_proxy;
        char *proxy_user;
index e57d053..8acbc66 100644 (file)
@@ -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";