Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix universe processing logic to avoid loops.
Vsevolod Stakhov committed 11 years ago
commit af8d1bde7e919935f9d999718fa534505b841fa7
parent 2f3c58d
3 files changed +11 -12
modified libpkg/pkg_jobs.c
@@ -1312,7 +1312,6 @@ jobs_solve_deinstall(struct pkg_jobs *j)

	j->solved = 1;
	pkg_jobs_process_delete_request(j);
-
	j->universe->processed = true;

	return( EPKG_OK);
}
@@ -1342,7 +1341,6 @@ jobs_solve_autoremove(struct pkg_jobs *j)

	j->solved = true;
	pkg_jobs_process_delete_request(j);
-
	j->universe->processed = true;

	return (EPKG_OK);
}
@@ -1494,10 +1492,8 @@ jobs_solve_install_upgrade(struct pkg_jobs *j)
			pkg_emit_progress_tick(jcount, jcount);
			LL_FREE(candidates, free);

-
			HASH_ITER(hh, j->request_add, req, rtmp) {
+
			HASH_ITER(hh, j->request_add, req, rtmp)
				pkg_jobs_universe_process(j->universe, req->item->pkg);
-
			}
-
			j->universe->processed = true;
		}
		else {
			HASH_ITER(hh, j->patterns, jp, jtmp) {
@@ -1513,10 +1509,8 @@ jobs_solve_install_upgrade(struct pkg_jobs *j)
			/*
			 * Need to iterate request one more time to recurse depends
			 */
-
			HASH_ITER(hh, j->request_add, req, rtmp) {
+
			HASH_ITER(hh, j->request_add, req, rtmp)
				pkg_jobs_universe_process(j->universe, req->item->pkg);
-
			}
-
			j->universe->processed = true;
		}
	}
	else {
@@ -2002,7 +1996,6 @@ pkg_jobs_apply(struct pkg_jobs *j)
						if (rc == EPKG_CONFLICT) {
							/* Cleanup results */
							LL_FREE(j->jobs, free);
-
							j->universe->processed = false;
							j->jobs = NULL;
							j->count = 0;
							has_conflicts = true;
modified libpkg/pkg_jobs_universe.c
@@ -440,6 +440,7 @@ pkg_jobs_universe_process_item(struct pkg_jobs_universe *universe, struct pkg *p
	unsigned flags = 0, job_flags;
	int rc = EPKG_OK;
	pkg_jobs_t type = universe->j->type;
+
	struct pkg_job_universe_item *found;

	job_flags = universe->j->flags;

@@ -447,15 +448,20 @@ pkg_jobs_universe_process_item(struct pkg_jobs_universe *universe, struct pkg *p
	 * Add pkg itself. If package is already seen then we check the `processed`
	 * flag that means that we have already tried to check our universe
	 */
-
	rc = pkg_jobs_universe_add_pkg(universe, pkg, false, result);
+
	rc = pkg_jobs_universe_add_pkg(universe, pkg, false, &found);
+
	if (result)
+
		*result = found;
+

	if (rc == EPKG_END) {
-
		if (universe->processed)
+
		if (found->processed)
			return (EPKG_OK);
	}
	else if (rc != EPKG_OK) {
		return (rc);
	}

+
	found->processed = true;
+

	/* Convert jobs flags to dependency logical flags */
	if (job_flags & PKG_FLAG_FORCE_MISSING)
		flags |= DEPS_FLAG_FORCE_MISSING;
modified libpkg/private/pkg_jobs.h
@@ -43,6 +43,7 @@ struct job_pattern;
struct pkg_job_universe_item {
	struct pkg *pkg;
	int priority;
+
	bool processed;
	UT_hash_handle hh;
	struct pkg_job_universe_item *next, *prev;
};
@@ -94,7 +95,6 @@ struct pkg_jobs_universe {
	struct pkg_job_provide *provides;
	struct pkg_job_replace *uid_replaces;
	struct pkg_jobs *j;
-
	bool processed;
	size_t nitems;
};