Skip to content

Commit

Permalink
modules/kvs: add treeobj param to internal getobj
Browse files Browse the repository at this point in the history
Add treeobj argument to getobj(), an internal client function,
so that we can implement kvs_getat() using it.
  • Loading branch information
garlick committed Sep 28, 2016
1 parent e173946 commit fda21a4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/modules/kvs/libkvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ char *kvsdir_key_at (kvsdir_t *dir, const char *name)
** GET
**/

static int getobj (flux_t h, const char *key, int flags, json_object **val)
static int getobj (flux_t h, json_object *rootdir, const char *key,
int flags, json_object **val)
{
flux_rpc_t *rpc = NULL;
const char *json_str;
Expand All @@ -341,7 +342,7 @@ static int getobj (flux_t h, const char *key, int flags, json_object **val)
goto done;
}
k = pathcat (kvs_getcwd (h), key);
if (!(in = kp_tget_enc (NULL, k, flags)))
if (!(in = kp_tget_enc (rootdir, k, flags)))
goto done;
if (!(rpc = flux_rpc (h, "kvs.get", Jtostr (in), FLUX_NODEID_ANY, 0)))
goto done;
Expand Down Expand Up @@ -371,7 +372,7 @@ int kvs_get (flux_t h, const char *key, char **val)
{
JSON v;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
return -1;
if (val)
*val = xstrdup (Jtostr (v));
Expand All @@ -382,7 +383,7 @@ int kvs_get (flux_t h, const char *key, char **val)
/* deprecated */
int kvs_get_obj (flux_t h, const char *key, JSON *val)
{
return getobj (h, key, 0, val);
return getobj (h, NULL, key, 0, val);
}

int kvs_get_dir (flux_t h, kvsdir_t **dir, const char *fmt, ...)
Expand Down Expand Up @@ -435,7 +436,7 @@ int kvs_get_symlink (flux_t h, const char *key, char **val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, KVS_PROTO_READLINK, &v) < 0)
if (getobj (h, NULL, key, KVS_PROTO_READLINK, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_string) {
errno = EPROTO;
Expand All @@ -455,7 +456,7 @@ int kvs_get_treeobj (flux_t h, const char *key, char **val)
const char *s;
int rc = -1;

if (getobj (h, key, KVS_PROTO_TREEOBJ, &v) < 0)
if (getobj (h, NULL, key, KVS_PROTO_TREEOBJ, &v) < 0)
goto done;
if (val) {
s = json_object_to_json_string_ext (v, JSON_C_TO_STRING_PLAIN);
Expand All @@ -472,7 +473,7 @@ int kvs_get_string (flux_t h, const char *key, char **val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_string) {
errno = EPROTO;
Expand All @@ -491,7 +492,7 @@ int kvs_get_int (flux_t h, const char *key, int *val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_int) {
errno = EPROTO;
Expand All @@ -510,7 +511,7 @@ int kvs_get_int64 (flux_t h, const char *key, int64_t *val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_int) {
errno = EPROTO;
Expand All @@ -529,7 +530,7 @@ int kvs_get_double (flux_t h, const char *key, double *val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_double) {
errno = EPROTO;
Expand All @@ -548,7 +549,7 @@ int kvs_get_boolean (flux_t h, const char *key, bool *val)
JSON v = NULL;
int rc = -1;

if (getobj (h, key, 0, &v) < 0)
if (getobj (h, NULL, key, 0, &v) < 0)
goto done;
if (json_object_get_type (v) != json_type_boolean) {
errno = EPROTO;
Expand Down Expand Up @@ -1651,7 +1652,7 @@ int kvsdir_unlink (kvsdir_t *dir, const char *name)
int kvs_copy (flux_t h, const char *from, const char *to)
{
JSON dirent;
if (getobj (h, from, KVS_PROTO_TREEOBJ, &dirent) < 0)
if (getobj (h, NULL, from, KVS_PROTO_TREEOBJ, &dirent) < 0)
return -1;
if (kvs_put_dirent (h, to, dirent) < 0) {
Jput (dirent);
Expand Down

0 comments on commit fda21a4

Please sign in to comment.