Skip to content

Commit

Permalink
Merge pull request #1338 from chu11/issue1290
Browse files Browse the repository at this point in the history
libflux/rpc: Rename flux_mrpcf() and flux_mrpc_getf()
  • Loading branch information
garlick authored Feb 14, 2018
2 parents 1b7d626 + a2445cd commit 7495042
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 83 deletions.
10 changes: 5 additions & 5 deletions doc/man3/flux_mrpc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ SYNOPSIS
flux_mrpc_t *flux_mrpc (flux_t *h, const char *topic, const char *json_str,
const char *nodeset, int flags);
flux_mrpc_t *flux_mrpcf (flux_t *h, const char *topic, const char *nodeset,
int flags, const char *fmt, ...);
flux_mrpc_t *flux_mrpc_pack (flux_t *h, const char *topic, const char *nodeset,
int flags, const char *fmt, ...);
int flux_mrpc_get (flux_mrpc_t *mrpc, const char **json_str);
int flux_mrpc_getf (flux_mrpc_t *mrpc, const char *fmt, ...);
int flux_mrpc_get_unpack (flux_mrpc_t *mrpc, const char *fmt, ...);
int flux_mrpc_get_raw (flux_mrpc_t *mrpc, const void **data, int *len);
Expand Down Expand Up @@ -87,7 +87,7 @@ a response containing an error, `flux_mrpc_get_nodeid()` will succeed,
while `flux_mrpc_get()` will fail. This allows the failing nodeid to
be determined.
`flux_mrpcf()` is a variant of `flux_mrpc()` that constructs a
`flux_mrpc_pack()` is a variant of `flux_mrpc()` that constructs a
JSON payload based on the provided _fmt_ string and variable arguments.
The _fmt_ string and variable arguments are passed internally to
jansson's `json_pack()` function. See below for details.
Expand Down Expand Up @@ -116,7 +116,7 @@ include::JSON_PACK.adoc[]
RETURN VALUE
------------
`flux_mrpc()` and `flux_mrpcf()` returns a flux_mrpc_t object
`flux_mrpc()` and `flux_mrpc_pack()` returns a flux_mrpc_t object
on success. On error, NULL is returned, and errno is set
appropriately.
Expand Down
12 changes: 6 additions & 6 deletions src/cmd/builtin/hwloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ static void request_hwloc_reload (flux_t *h, const char *nodeset,
flux_mrpc_t *mrpc;

if (!walk_topology) {
if (!(mrpc = flux_mrpcf (h, "resource-hwloc.reload",
nodeset, 0, "{}")))
log_err_exit ("flux_mrpcf");
if (!(mrpc = flux_mrpc_pack (h, "resource-hwloc.reload",
nodeset, 0, "{}")))
log_err_exit ("flux_mrpc_pack");
}
else {
bool v = hwloc_reload_bool_value (walk_topology);

if (!(mrpc = flux_mrpcf (h, "resource-hwloc.reload", nodeset, 0,
"{ s:b }", "walk_topology", v)))
log_err_exit ("flux_mrpcf");
if (!(mrpc = flux_mrpc_pack (h, "resource-hwloc.reload", nodeset, 0,
"{ s:b }", "walk_topology", v)))
log_err_exit ("flux_mrpc_pack");
}

do {
Expand Down
20 changes: 10 additions & 10 deletions src/cmd/flux-ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ void ping_continuation (flux_mrpc_t *mrpc, void *arg)
tstat_t *tstat = pdata->tstat;
uint32_t rolemask, userid;

if (flux_mrpc_getf (mrpc, "{ s:i s:I s:I s:s s:s s:i s:i !}",
"seq", &seq,
"time.tv_sec", &sec,
"time.tv_nsec", &nsec,
"pad", &pad,
"route", &route,
"userid", &userid,
"rolemask", &rolemask) < 0) {
if (flux_mrpc_get_unpack (mrpc, "{ s:i s:I s:I s:s s:s s:i s:i !}",
"seq", &seq,
"time.tv_sec", &sec,
"time.tv_nsec", &nsec,
"pad", &pad,
"route", &route,
"userid", &userid,
"rolemask", &rolemask) < 0) {
log_err ("%s!%s", ctx->rank, ctx->topic);
goto done;
}
Expand Down Expand Up @@ -173,14 +173,14 @@ void send_ping (struct ping_ctx *ctx)

monotime (&t0);

mrpc = flux_mrpcf (ctx->h, ctx->topic, ctx->rank, 0,
mrpc = flux_mrpc_pack (ctx->h, ctx->topic, ctx->rank, 0,
"{s:i s:I s:I s:s}",
"seq", ctx->send_count,
"time.tv_sec", (uint64_t)t0.tv_sec,
"time.tv_nsec", (uint64_t)t0.tv_nsec,
"pad", ctx->pad);
if (!mrpc)
log_err_exit ("flux_mrpcf");
log_err_exit ("flux_mrpc_pack");
if (flux_mrpc_aux_set (mrpc, "ping", pdata, ping_data_free) < 0)
log_err_exit ("flux_mrpc_aux_set");
if (flux_mrpc_then (mrpc, ping_continuation, ctx) < 0)
Expand Down
18 changes: 9 additions & 9 deletions src/common/libflux/mrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ int flux_mrpc_get_raw (flux_mrpc_t *mrpc, const void **data, int *len)
return rc;
}

static int flux_mrpc_vgetf (flux_mrpc_t *mrpc, const char *fmt, va_list ap)
static int flux_mrpc_vget_unpack (flux_mrpc_t *mrpc, const char *fmt, va_list ap)
{
int rc = -1;
const char *json_str;
Expand All @@ -277,13 +277,13 @@ static int flux_mrpc_vgetf (flux_mrpc_t *mrpc, const char *fmt, va_list ap)
return rc;
}

int flux_mrpc_getf (flux_mrpc_t *mrpc, const char *fmt, ...)
int flux_mrpc_get_unpack (flux_mrpc_t *mrpc, const char *fmt, ...)
{
va_list ap;
int rc;

va_start (ap, fmt);
rc = flux_mrpc_vgetf (mrpc, fmt, ap);
rc = flux_mrpc_vget_unpack (mrpc, fmt, ap);
va_end (ap);

return rc;
Expand Down Expand Up @@ -505,12 +505,12 @@ flux_mrpc_t *flux_mrpc (flux_t *h,
return rc;
}

flux_mrpc_t *flux_mrpcf (flux_t *h,
const char *topic,
const char *nodeset,
int flags,
const char *fmt,
...)
flux_mrpc_t *flux_mrpc_pack (flux_t *h,
const char *topic,
const char *nodeset,
int flags,
const char *fmt,
...)
{
flux_msg_t *msg;
flux_mrpc_t *rc = NULL;
Expand Down
6 changes: 3 additions & 3 deletions src/common/libflux/mrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ flux_mrpc_t *flux_mrpc (flux_t *h, const char *topic, const char *json_str,
/* Variant of flux_mrpc that encodes a json payload using jansson
* pack format strings.
*/
flux_mrpc_t *flux_mrpcf (flux_t *h, const char *topic, const char *nodeset,
int flags, const char *fmt, ...);
flux_mrpc_t *flux_mrpc_pack (flux_t *h, const char *topic, const char *nodeset,
int flags, const char *fmt, ...);

/* Destroy an mrpc, invalidating previous payload returned by flux_mrpc_get().
*/
Expand All @@ -48,7 +48,7 @@ int flux_mrpc_get (flux_mrpc_t *mrpc, const char **json_str);
* jansson pack/unpack format strings. Returned items are
* invalidated by flux_mrpc_destroy() or flux_mrpc_next().
*/
int flux_mrpc_getf (flux_mrpc_t *mrpc, const char *fmt, ...);
int flux_mrpc_get_unpack (flux_mrpc_t *mrpc, const char *fmt, ...);

/* Wait for response if necessary, then decode nodeid request was sent to.
* This function succedes even if the RPC service is returning an error.
Expand Down
4 changes: 2 additions & 2 deletions t/kvs/watch_disconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void send_watch_requests (flux_t *h, const char *key)
int flags = KVS_WATCH_FIRST;
flux_mrpc_t *r;

if (!(r = flux_mrpcf (h, "kvs.watch", "all", 0, "{s:s s:s s:i s:n}",
if (!(r = flux_mrpc_pack (h, "kvs.watch", "all", 0, "{s:s s:s s:i s:n}",
"key", key,
"namespace", KVS_PRIMARY_NAMESPACE,
"flags", flags,
Expand All @@ -42,7 +42,7 @@ int count_watchers (flux_t *h)
log_err_exit ("flux_mrpc kvs.stats.get");
do {
json_t *ns, *p;
if (flux_mrpc_getf (r, "{ s:o }", "namespace", &ns) < 0)
if (flux_mrpc_get_unpack (r, "{ s:o }", "namespace", &ns) < 0)
log_err_exit ("kvs.stats.get namespace");
if (json_unpack (ns, "{ s:o }", KVS_PRIMARY_NAMESPACE, &p) < 0)
log_err_exit ("kvs.stats.get %s", KVS_PRIMARY_NAMESPACE);
Expand Down
Loading

0 comments on commit 7495042

Please sign in to comment.