New option in conffile to set libfetch's limit (seconds) in timed out connections.

This commit is contained in:
Juan RP 2011-06-22 09:53:44 +02:00
parent 6b4aaae971
commit fbfa9c5960
5 changed files with 28 additions and 2 deletions

5
NEWS
View File

@ -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

View File

@ -18,6 +18,10 @@
<key>fetch-cache-connections-per-host</key>
<integer>6</integer>
<!-- Default timeout limit for connections, in seconds. -->
<key>fetch-timeout-connection</key>
<integer>30</integer>
<!-- Repository list -->
<key>repositories</key>
<array>

View File

@ -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
*

View File

@ -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.
*/

View File

@ -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.