Skip to content

Commit

Permalink
Merge pull request #1213 from chu11/misccleanup9
Browse files Browse the repository at this point in the history
Misc KVS cleanup & minor fixes
  • Loading branch information
garlick authored Sep 27, 2017
2 parents aa3cac0 + f7a8984 commit 92a797f
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 199 deletions.
6 changes: 4 additions & 2 deletions src/modules/kvs/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ int cache_entry_set_dirty (struct cache_entry *hp, bool val)
}
}
}
return 0;
}
return 0;
return -1;
}

int cache_entry_clear_dirty (struct cache_entry *hp)
Expand Down Expand Up @@ -155,8 +156,9 @@ int cache_entry_set_json (struct cache_entry *hp, json_t *o)
json_decref (hp->o);
hp->o = NULL;
}
return 0;
}
return 0;
return -1;
}

void cache_entry_destroy (void *arg)
Expand Down
11 changes: 4 additions & 7 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ static int content_load_request_send (kvs_ctx_t *ctx, const href_t ref)
}

/* Return 0 on success, -1 on error. Set stall variable appropriately */
static int load (kvs_ctx_t *ctx, const href_t ref, wait_t *wait, json_t **op,
bool *stall)
static int load (kvs_ctx_t *ctx, const href_t ref, wait_t *wait, bool *stall)
{
struct cache_entry *hp = cache_lookup (ctx->cache, ref, ctx->epoch);
int saved_errno, ret;
Expand Down Expand Up @@ -287,8 +286,6 @@ static int load (kvs_ctx_t *ctx, const href_t ref, wait_t *wait, json_t **op,
return 0;
}

if (op)
*op = cache_entry_get_json (hp);
if (stall)
*stall = false;
return 0;
Expand Down Expand Up @@ -413,7 +410,7 @@ static int commit_load_cb (commit_t *c, const char *ref, void *data)
struct commit_cb_data *cbd = data;
bool stall;

if (load (cbd->ctx, ref, cbd->wait, NULL, &stall) < 0) {
if (load (cbd->ctx, ref, cbd->wait, &stall) < 0) {
cbd->errnum = errno;
flux_log_error (cbd->ctx->h, "%s: load", __FUNCTION__);
return -1;
Expand Down Expand Up @@ -731,7 +728,7 @@ static void get_request_cb (flux_t *h, flux_msg_handler_t *w,

if (!(wait = wait_create_msg_handler (h, w, msg, get_request_cb, lh)))
goto done;
if (load (ctx, missing_ref, wait, NULL, &stall) < 0) {
if (load (ctx, missing_ref, wait, &stall) < 0) {
flux_log_error (h, "%s: load", __FUNCTION__);
goto done;
}
Expand Down Expand Up @@ -839,7 +836,7 @@ static void watch_request_cb (flux_t *h, flux_msg_handler_t *w,

if (!(wait = wait_create_msg_handler (h, w, msg, watch_request_cb, lh)))
goto done;
if (load (ctx, missing_ref, wait, NULL, &stall) < 0) {
if (load (ctx, missing_ref, wait, &stall) < 0) {
flux_log_error (h, "%s: load", __FUNCTION__);
goto done;
}
Expand Down
18 changes: 17 additions & 1 deletion src/modules/kvs/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ static bool walk (lookup_t *lh)
lh->missing_ref = refstr;
goto stall;
}

if (!treeobj_is_dir (dir)) {
/* dirref pointed to non-dir error, special case when
* root_dirent is bad, is EINVAL from user.
*/
if (wl->depth == 0 && wl->dirent == lh->root_dirent)
lh->errnum = EINVAL;
else
lh->errnum = EPERM;
goto error;
}
} else {
/* Unexpected dirent type */
if (treeobj_is_valref (wl->dirent)
Expand Down Expand Up @@ -545,7 +556,8 @@ int lookup_set_current_epoch (lookup_t *lh, int epoch)
return -1;
}

int lookup_set_aux_data (lookup_t *lh, void *data) {
int lookup_set_aux_data (lookup_t *lh, void *data)
{
if (lh && lh->magic == LOOKUP_MAGIC) {
lh->aux = data;
return 0;
Expand Down Expand Up @@ -588,6 +600,10 @@ bool lookup (lookup_t *lh)
lh->missing_ref = lh->root_ref;
goto stall;
}
if (!treeobj_is_dir (valtmp)) {
lh->errnum = EINVAL;
goto done;
}
lh->val = json_incref (valtmp);
}
goto done;
Expand Down
Loading

0 comments on commit 92a797f

Please sign in to comment.