aboutsummaryrefslogtreecommitdiff
path: root/rcynic/rcynic.c
diff options
context:
space:
mode:
authorMichael Elkins <melkins@tislabs.com>2011-11-11 01:24:42 +0000
committerMichael Elkins <melkins@tislabs.com>2011-11-11 01:24:42 +0000
commitdc9809bdcea60e86bb831f72e4c7da0da17bcd2e (patch)
tree79728597e2316022d2afa69e950bd9bbd9df9f72 /rcynic/rcynic.c
parent342e978ef4f65bb00b45aaf120a8b9fd1f1fbde3 (diff)
parentacf83a1b20cc2802dad24aa2422c0bd54951c8e7 (diff)
merge with ^/trunk
svn path=/branches/tk103/; revision=4084
Diffstat (limited to 'rcynic/rcynic.c')
-rw-r--r--rcynic/rcynic.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/rcynic/rcynic.c b/rcynic/rcynic.c
index 3c7df816..64f44096 100644
--- a/rcynic/rcynic.c
+++ b/rcynic/rcynic.c
@@ -1554,6 +1554,17 @@ static walk_ctx_t *walk_ctx_stack_head(STACK_OF(walk_ctx_t) *wsk)
}
/**
+ * Whether we're done iterating over a walk context. Think of this as
+ * the thing you call (negated) in the second clause of a conceptual
+ * "for" loop.
+ */
+static int walk_ctx_loop_done(STACK_OF(walk_ctx_t) *wsk)
+{
+ walk_ctx_t *w = walk_ctx_stack_head(wsk);
+ return wsk == NULL || w == NULL || w->state >= walk_state_done;
+}
+
+/**
* Walk context iterator. Think of this as the thing you call in the
* third clause of a conceptual "for" loop: this reinitializes as
* necessary for the next pass through the loop.
@@ -1579,26 +1590,17 @@ static void walk_ctx_loop_next(const rcynic_ctx_t *rc, STACK_OF(walk_ctx_t) *wsk
return;
}
- if (w->state < walk_state_done) {
+ while (!walk_ctx_loop_done(wsk)) {
w->state++;
w->manifest_iteration = 0;
w->filename_iteration = 0;
sk_OPENSSL_STRING_pop_free(w->filenames, OPENSSL_STRING_free);
w->filenames = directory_filenames(rc, w->state, &w->certinfo.sia);
+ if (w->manifest != NULL || w->filenames != NULL)
+ return;
}
}
-/**
- * Whether we're done iterating over a walk context. Think of this as
- * the thing you call (negated) in the second clause of a conceptual
- * "for" loop.
- */
-static int walk_ctx_loop_done(STACK_OF(walk_ctx_t) *wsk)
-{
- walk_ctx_t *w = walk_ctx_stack_head(wsk);
- return wsk == NULL || w == NULL || w->state >= walk_state_done;
-}
-
static int check_manifest(rcynic_ctx_t *rc, STACK_OF(walk_ctx_t) *wsk);
/**
@@ -1626,17 +1628,16 @@ static void walk_ctx_loop_init(rcynic_ctx_t *rc, STACK_OF(walk_ctx_t) *wsk)
if (!w->manifest)
logmsg(rc, log_telemetry, "Couldn't get manifest %s, blundering onward", w->certinfo.manifest.s);
- assert(w->filenames == NULL);
- w->filenames = directory_filenames(rc, w->state, &w->certinfo.sia);
-
- w->stale_manifest = w->manifest != NULL && X509_cmp_current_time(w->manifest->nextUpdate) < 0;
-
w->manifest_iteration = 0;
w->filename_iteration = 0;
w->state++;
-
assert(w->state == walk_state_current);
+ assert(w->filenames == NULL);
+ w->filenames = directory_filenames(rc, w->state, &w->certinfo.sia);
+
+ w->stale_manifest = w->manifest != NULL && X509_cmp_current_time(w->manifest->nextUpdate) < 0;
+
while (!walk_ctx_loop_done(wsk) &&
(w->manifest == NULL || w->manifest_iteration >= sk_FileAndHash_num(w->manifest->fileList)) &&
(w->filenames == NULL || w->filename_iteration >= sk_OPENSSL_STRING_num(w->filenames)))