From 088baa76990e3f468b140f2896ca59e0727365c1 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 24 Jan 2010 16:31:56 +0100 Subject: [PATCH] Add defs for default fetch cache connection limits and use them in xbps_fetch_cache_connection() if 0 is passed as argument. xbps-bin: enable fetch cached connection when downloading binpkgs. --HG-- extra : convert_revision : xtraeme%40gmail.com-20100124153156-4updprik11nwi7c1 --- bin/xbps-bin/install.c | 3 +++ include/xbps_api.h | 20 ++++++++++++++++++-- lib/download.c | 7 ++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index b075e752..ecd5101d 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -102,6 +102,9 @@ download_package_list(prop_object_iterator_t iter) if (cachedir == NULL) return EINVAL; + /* Set default limit of global and per-host cached connections */ + xbps_fetch_set_cache_connection(0, 0); + while ((obj = prop_object_iterator_next(iter)) != NULL) { found_binpkg = false; if (!prop_dictionary_get_cstring_nocopy(obj, diff --git a/include/xbps_api.h b/include/xbps_api.h index 391cb4e6..223ef16d 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -217,6 +217,20 @@ int xbps_cmpver(const char *pkg1, const char *pkg2); /** @addtogroup download */ /*@{*/ +/** + * @def XBPS_FETCH_CACHECONN + * + * Default (global) limit of cached connections used in libfetch. + */ +#define XBPS_FETCH_CACHECONN 8 + +/** + * @def XBPS_FETCH_CACHECONN_HOST + * + * Default (per host) limit of cached connections used in libfetch. + */ +#define XBPS_FETCH_CACHECONN_HOST 16 + /** * Download a file from a remote URL. * @@ -237,8 +251,10 @@ int xbps_fetch_file(const char *uri, /** * Sets the libfetch's cache connection limits. * - * @param[in] global Number of global cached connections, by default 8. - * @param[in] per_host Number of per host cached connections, by default 16. + * @param[in] global Number of global cached connections, if set to 0 + * by default it's set to XBPS_FETCH_CACHECONN. + * @param[in] per_host Number of per host cached connections, if set to 0 + * by default it's set to XBPS_FETCH_CACHECONN_HOST. */ void xbps_fetch_set_cache_connection(int global, int per_host); diff --git a/lib/download.c b/lib/download.c index b34c5570..a7522419 100644 --- a/lib/download.c +++ b/lib/download.c @@ -58,9 +58,6 @@ struct xferstat { const char *name; }; -static int cache_connections = 8; -static int cache_connections_host = 16; - /* * Compute and display ETA */ @@ -197,9 +194,9 @@ void xbps_fetch_set_cache_connection(int global, int per_host) { if (global == 0) - global = cache_connections; + global = XBPS_FETCH_CACHECONN; if (per_host == 0) - per_host = cache_connections_host; + per_host = XBPS_FETCH_CACHECONN_HOST; fetchConnectionCacheInit(global, per_host); }