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 bab8f573b66107e2ef8c00329902380d973786a0..08855ebcd3d8a7bfbc2c64d61b8e059ab5b22417 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 b63a1e6fdf7211af13367db377082e2ba8b36ee7..37f95a1a9935d673cbba5f786d58c150a74e2fa7 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 e57d053a5897c861e671489e0f521e60f7a5925c..8acbc6681fae187085821ab50feaa91a4a43be6c 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";