Some changes for the XBPS libfetch's frontend code.

1) Raise the cache connection settings to more sane defaults (8->6, 16->2).
2) Introduce xbps_fetch_unset_cache_connection() to drop the caches.
This commit is contained in:
Juan RP 2010-11-03 12:23:57 +01:00
parent 9c60862e0f
commit 8ef8d86c12
3 changed files with 16 additions and 3 deletions

View File

@ -120,6 +120,7 @@ static void
cleanup(int signum) cleanup(int signum)
{ {
xbps_regpkgs_dictionary_release(); xbps_regpkgs_dictionary_release();
xbps_fetch_unset_cache_connection();
exit(signum); exit(signum);
} }

View File

@ -223,14 +223,14 @@ int xbps_cmpver(const char *pkg1, const char *pkg2);
* *
* Default (global) limit of cached connections used in libfetch. * Default (global) limit of cached connections used in libfetch.
*/ */
#define XBPS_FETCH_CACHECONN 8 #define XBPS_FETCH_CACHECONN 6
/** /**
* @def XBPS_FETCH_CACHECONN_HOST * @def XBPS_FETCH_CACHECONN_HOST
* *
* Default (per host) limit of cached connections used in libfetch. * Default (per host) limit of cached connections used in libfetch.
*/ */
#define XBPS_FETCH_CACHECONN_HOST 16 #define XBPS_FETCH_CACHECONN_HOST 2
/** /**
* Download a file from a remote URL. * Download a file from a remote URL.
@ -259,6 +259,11 @@ int xbps_fetch_file(const char *uri,
*/ */
void xbps_fetch_set_cache_connection(int global, int per_host); void xbps_fetch_set_cache_connection(int global, int per_host);
/**
* Destroys the libfetch's cache connection established.
*/
void xbps_fetch_unset_cache_connection(void);
/** /**
* Returns last error string reported by xbps_fetch_file(). * Returns last error string reported by xbps_fetch_file().
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009 Juan Romero Pardines * Copyright (c) 2009-2010 Juan Romero Pardines
* Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved. * All rights reserved.
* *
@ -130,6 +130,7 @@ stat_display(struct xferstat *xsp)
if (xsp->size > 0 && xsp->rcvd > 0 && if (xsp->size > 0 && xsp->rcvd > 0 &&
xsp->last.tv_sec >= xsp->start.tv_sec + 10) xsp->last.tv_sec >= xsp->start.tv_sec + 10)
fprintf(stderr, " ETA: %s", stat_eta(xsp)); fprintf(stderr, " ETA: %s", stat_eta(xsp));
fprintf(stderr, "\033[K");
} }
/* /*
@ -201,6 +202,12 @@ xbps_fetch_set_cache_connection(int global, int per_host)
fetchConnectionCacheInit(global, per_host); fetchConnectionCacheInit(global, per_host);
} }
void
xbps_fetch_unset_cache_connection(void)
{
fetchConnectionCacheClose();
}
int int
xbps_fetch_file(const char *uri, const char *outputdir, bool refetch, xbps_fetch_file(const char *uri, const char *outputdir, bool refetch,
const char *flags) const char *flags)