Skip to content

Commit

Permalink
Merge pull request #1402 from chu11/issue1341-part3-try2
Browse files Browse the repository at this point in the history
kvs: minor cleanup & refactoring
  • Loading branch information
garlick authored Mar 30, 2018
2 parents 25f7d40 + 6629a18 commit a7402b5
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/modules/kvs/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct lookup {
LOOKUP_STATE_INIT,
LOOKUP_STATE_CHECK_NAMESPACE,
LOOKUP_STATE_CHECK_ROOT,
LOOKUP_STATE_WALK_INIT,
LOOKUP_STATE_WALK,
LOOKUP_STATE_VALUE,
LOOKUP_STATE_FINISHED,
Expand Down Expand Up @@ -840,17 +841,6 @@ lookup_process_t lookup (lookup_t *lh)
}
}

if (!(lh->root_dirent = treeobj_create_dirref (lh->root_ref))) {
lh->errnum = errno;
goto error;
}

/* initialize walk - first depth is level 0 */
if (!walk_levels_push (lh, lh->path, 0)) {
lh->errnum = errno;
goto error;
}

lh->state = LOOKUP_STATE_CHECK_ROOT;
/* fallthrough */
case LOOKUP_STATE_CHECK_ROOT:
Expand All @@ -876,7 +866,6 @@ lookup_process_t lookup (lookup_t *lh)
lh->root_ref,
lh->current_epoch))
|| !cache_entry_get_valid (entry)) {
lh->state = LOOKUP_STATE_CHECK_ROOT;
lh->missing_ref = lh->root_ref;
return LOOKUP_PROCESS_LOAD_MISSING_REFS;
}
Expand All @@ -899,6 +888,21 @@ lookup_process_t lookup (lookup_t *lh)
goto done;
}

lh->state = LOOKUP_STATE_WALK_INIT;
/* fallthrough */
case LOOKUP_STATE_WALK_INIT:
/* initialize walk - first depth is level 0 */

if (!(lh->root_dirent = treeobj_create_dirref (lh->root_ref))) {
lh->errnum = errno;
goto error;
}

if (!walk_levels_push (lh, lh->path, 0)) {
lh->errnum = errno;
goto error;
}

lh->state = LOOKUP_STATE_WALK;
/* fallthrough */
case LOOKUP_STATE_WALK:
Expand Down

0 comments on commit a7402b5

Please sign in to comment.