int flux_rpc_get (flux_rpc_t *rpc, uint32_t *nodeid, const char **json_str) { int rc = -1; if (rpc->oneway) { errno = EINVAL; goto done; } if (!rpc->rx_msg && !(rpc->rx_msg = flux_recv (rpc->h, rpc->m, 0))) goto done; flux_msg_destroy (rpc->rx_msg_consumed); /* invalidate last-got payload */ rpc->rx_msg_consumed = rpc->rx_msg; rpc->rx_msg = NULL; rpc->rx_count++; if (nodeid) { uint32_t matchtag; if (flux_msg_get_matchtag (rpc->rx_msg_consumed, &matchtag) < 0) goto done; *nodeid = lookup_nodeid (rpc, matchtag); } if (flux_response_decode (rpc->rx_msg_consumed, NULL, json_str) < 0) goto done; rc = 0; done: return rc; }
static int fastpath_response_lookup (struct dispatch *d, const flux_msg_t *msg, struct flux_msg_handler **hpp) { uint32_t tag, group; if (flux_msg_get_matchtag (msg, &tag) < 0) return -1; group = tag>>FLUX_MATCHTAG_GROUP_SHIFT; if (group > 0) return fastpath_get (&d->group, group, hpp); else return fastpath_get (&d->norm, tag, hpp); }
int flux_rpc_get_nodeid (flux_rpc_t *rpc, uint32_t *nodeid) { int rc = -1; uint32_t tag; assert (rpc->magic == RPC_MAGIC); if (rpc_get (rpc) < 0) goto done; if (flux_msg_get_matchtag (rpc->rx_msg, &tag) < 0) goto done; if ((tag & FLUX_MATCHTAG_GROUP_MASK) > 0) *nodeid = tag & ~FLUX_MATCHTAG_GROUP_MASK; else *nodeid = rpc->nodeid; rc = 0; done: return rc; }