libxbps: do not loop forever on errors while syncing a remote repo.

This commit is contained in:
Juan RP 2011-07-14 00:13:25 +02:00
parent 12ac81e00e
commit f6476e210c
3 changed files with 31 additions and 5 deletions

5
NEWS
View File

@ -1,5 +1,10 @@
xbps-0.9.1 (???): xbps-0.9.1 (???):
* libxbps: xbps_repository_pool no longer loops forever if a package
index plist file cannot be fetched due to network problems, or
if the file is not available anymore; the repository will be
ignored.
* xbps-repo(8): the 'genindex' failed to register in pkg-index * xbps-repo(8): the 'genindex' failed to register in pkg-index
packages less than on equal than any other package providing the packages less than on equal than any other package providing the
same package name. Ignore packages providing virtual packages. same package name. Ignore packages providing virtual packages.

View File

@ -59,7 +59,7 @@
* @def XBPS_RELVER * @def XBPS_RELVER
* Current library release date. * Current library release date.
*/ */
#define XBPS_RELVER "API: 20110622 INDEX: " XBPS_PKGINDEX_VERSION #define XBPS_RELVER "API: 20110714 INDEX: " XBPS_PKGINDEX_VERSION
/** /**
* @def XBPS_META_PATH * @def XBPS_META_PATH

View File

@ -47,6 +47,12 @@ static SIMPLEQ_HEAD(rpool_head, repository_pool) rpool_queue =
static bool repolist_initialized; static bool repolist_initialized;
#define FETCH_ERROR(x) ((x == FETCH_UNAVAIL) || \
(x == FETCH_NETWORK) || \
(x == FETCH_ABORT) || \
(x == FETCH_TIMEOUT) || \
(x == FETCH_DOWN))
int HIDDEN int HIDDEN
xbps_repository_pool_init(void) xbps_repository_pool_init(void)
{ {
@ -112,10 +118,25 @@ xbps_repository_pool_init(void)
"`%s'...\n", repouri); "`%s'...\n", repouri);
rv = xbps_repository_sync_pkg_index(repouri); rv = xbps_repository_sync_pkg_index(repouri);
if (rv == -1) { if (rv == -1) {
xbps_error_printf("failed to sync `%s'" const char *fetcherr =
": %s %s\n", xbps_fetch_error_string();
repouri, strerror(errno),
xbps_fetch_error_string()); xbps_error_printf("failed to sync "
"repository `%s': %s%s\n",
repouri,
errno ? strerror(errno) : "",
fetchLastErrCode ? fetcherr : "");
/*
* Ignore if the file cannot be
* fetched due to network, missing
* file, moved, etc.
*/
if (FETCH_ERROR(fetchLastErrCode)) {
rv = 0;
free(plist);
continue;
}
rv = errno; rv = errno;
free(plist); free(plist);
goto out; goto out;