socsvn commit: r256967 - soc2013/mattbw/backend/jobs
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Thu Sep 5 20:48:23 UTC 2013
Author: mattbw
Date: Thu Sep 5 20:48:23 2013
New Revision: 256967
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256967
Log:
Split out the jobs checking function a little.
Modified:
soc2013/mattbw/backend/jobs/check.c
Modified: soc2013/mattbw/backend/jobs/check.c
==============================================================================
--- soc2013/mattbw/backend/jobs/check.c Thu Sep 5 19:25:36 2013 (r256966)
+++ soc2013/mattbw/backend/jobs/check.c Thu Sep 5 20:48:23 2013 (r256967)
@@ -33,7 +33,8 @@
#include "../query.h" /* query_... */
#include "check.h" /* jobs_check_... */
-static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever);
+static bool check_package(struct pkg *pkg, struct query_id *query_ids, guint count, bool reject_non_updates);
+static bool jobs_check_id_on_package(struct pkg *pkg, struct query_id *query_id, const char *namever);
static struct pkg *jobs_check_query_ids(struct pkg_jobs *jobs, struct query_id *query_ids, guint count, bool reject_non_updates);
/* Checks a solved job against a string vector of PackageIDs to ensure any
@@ -94,55 +95,77 @@
guint count, bool reject_non_updates)
{
bool success;
- guint i;
int err;
- char *namever;
struct pkg *package;
assert(jobs != NULL);
assert(query_ids != NULL);
assert(0 < count);
-
package = NULL;
success = true;
while (success) {
err = pkg_jobs(jobs, &package);
- if (err != EPKG_OK) {
- /* Did we reach the end of the job iterator? */
- if (err != EPKG_END) {
- success = false;
- }
+ if (err == EPKG_OK) {
+ success = check_package(package, query_ids,
+ count, reject_non_updates);
+ } else if (err == EPKG_END) {
+ /*
+ * Only return a package if it failed to match.
+ * If we've reached this far all of them have
+ * matched, so don't return one!
+ */
+ package = NULL;
break;
+ } else {
+ /* Abnormal termination */
+ success = false;
}
+ }
- assert(package != NULL);
+ return package;
+}
- namever = namever_from_package(package);
- if (namever == NULL) {
- success = false;
- }
+/*
+ * Checks a single job target package against a set of candidate
+ * query IDs to make sure that the originally requested packages in
+ * the job have been resolved properly.
+ */
+static bool
+check_package(struct pkg *package, struct query_id *query_ids,
+ guint count, bool reject_non_updates)
+{
+ bool success;
+ guint i;
+ char *namever;
+
+ assert(package != NULL);
+
+ success = true;
+
+ namever = namever_from_package(package);
+ if (namever == NULL) {
+ success = false;
+ }
- for (i = 0; i < count; i++) {
- if (!success) {
- /* Leave the for loop, not the while loop. */
- break;
- }
-
- assert(success);
- success = jobs_check_id_on_package(package,
- query_ids + i,
- namever);
-
- if (success && reject_non_updates &&
- pkgutils_pkg_install_state(package) !=
- PK_INFO_ENUM_UPDATING) {
- success = false;
- }
+ for (i = 0; i < count; i++) {
+ if (!success) {
+ break;
}
- /* Do not free the struct pkg, we actually don't own it. */
+ assert(success);
+ success = jobs_check_id_on_package(package,
+ query_ids + i,
+ namever);
+
+ if (success && reject_non_updates &&
+ pkgutils_pkg_install_state(package) !=
+ PK_INFO_ENUM_UPDATING) {
+ success = false;
+ }
}
- return success ? NULL : package;
+ /* Do not free the struct pkg, we actually don't own it. */
+
+ return success;
}
More information about the svn-soc-all
mailing list