diff --git a/NEWS b/NEWS
index 370d035d..28b4a81f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
xbps-0.9.0 (???):
+ * The configuration file now accepts a new option "fetch-timeout-connection",
+ to specify the limit to wait (in seconds) of timed out connections when
+ fetching files. It's set to 30 in configuration file, and if not set it
+ also defaults to 30 seconds.
+
* The configuration file now accepts new options to change rootdir
(same than -r in xbps-bin(8)), cachedir (same than -c in xbps-bin(8))
and fetching cache connection limits. If settings are specified via
diff --git a/etc/xbps-conf.plist b/etc/xbps-conf.plist
index 5a77182d..f953a327 100644
--- a/etc/xbps-conf.plist
+++ b/etc/xbps-conf.plist
@@ -18,6 +18,10 @@
fetch-cache-connections-per-host
6
+
+ fetch-timeout-connection
+ 30
+
repositories
diff --git a/include/xbps_api.h b/include/xbps_api.h
index 22242b73..be491265 100644
--- a/include/xbps_api.h
+++ b/include/xbps_api.h
@@ -59,7 +59,7 @@
* @def XBPS_RELVER
* Current library release date.
*/
-#define XBPS_RELVER "API: 20110604 INDEX: " XBPS_PKGINDEX_VERSION
+#define XBPS_RELVER "API: 20110622 INDEX: " XBPS_PKGINDEX_VERSION
/**
* @def XBPS_META_PATH
@@ -187,6 +187,14 @@ struct xbps_handle {
* as argument to the \a xbps_fetch_cb function callback.
*/
struct xbps_fetch_progress_data *xfpd;
+ /**
+ * @private fetch_timeout
+ *
+ * Unsigned integer to specify libfetch's timeout limit.
+ * If not set, it defaults to 30 (in seconds). This is set internally
+ * by the API from a setting in configuration file.
+ */
+ uint16_t fetch_timeout;
/**
* @var flags
*
diff --git a/lib/download.c b/lib/download.c
index ac1463ad..42e2a5e0 100644
--- a/lib/download.c
+++ b/lib/download.c
@@ -106,9 +106,14 @@ xbps_fetch_file(const char *uri,
assert(outputdir != NULL);
fetchLastErrCode = 0;
- fetchTimeout = 30; /* 30 seconds of timeout */
xhp = xbps_handle_get();
+
+ if (xhp->fetch_timeout != 0)
+ fetchTimeout = xhp->fetch_timeout;
+ else
+ fetchTimeout = 30; /* 30s if not set in configuration file. */
+
/*
* Get the filename specified in URI argument.
*/
diff --git a/lib/initend.c b/lib/initend.c
index 2eab28c2..8bd784a6 100644
--- a/lib/initend.c
+++ b/lib/initend.c
@@ -84,6 +84,8 @@ xbps_init(struct xbps_handle *xh)
"fetch-cache-connections", &fetch_cache_conn);
prop_dictionary_get_uint16(xhp->conf_dictionary,
"fetch-cache-connections-per-host", &fetch_cache_conn_host);
+ prop_dictionary_get_uint16(xhp->conf_dictionary,
+ "fetch-timeout-connection", &xhp->fetch_timeout);
}
/*
@@ -118,6 +120,8 @@ xbps_init(struct xbps_handle *xh)
__func__, xhp->rootdir, xhp->cachedir, xhp->conffile);
xbps_dbg_printf("%s: fetch_cache_conn: %zu fetch_cache_host: %zu\n",
__func__, fetch_cache_conn, fetch_cache_conn_host);
+ xbps_dbg_printf("%s: fetch_timeout: %zu\n", __func__,
+ xhp->fetch_timeout);
/*
* Initialize repository pool.