/* N.B. if a new message arrives with an unconsumed one in the rpc handle, * push the new one back to to the receive queue so it will trigger another * reactor callback and handle the cached one now. * The reactor will repeatedly call the continuation (level-triggered) * until all received responses are consumed. */ static void rpc_cb (flux_t h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { flux_rpc_t *rpc = arg; assert (rpc->then_cb != NULL); flux_rpc_usecount_incr (rpc); if (rpc->rx_msg) { if (flux_requeue (rpc->h, msg, FLUX_RQ_HEAD) < 0) goto done; } else { if (!(rpc->rx_msg = flux_msg_copy (msg, true))) goto done; } rpc->then_cb (rpc, rpc->then_arg); if (rpc->rx_msg) { if (flux_requeue (rpc->h, rpc->rx_msg, FLUX_RQ_HEAD) < 0) goto done; rpc->rx_msg = NULL; } done: /* no good way to report flux_requeue() errors */ if (flux_rpc_completed (rpc)) flux_msg_handler_stop (rpc->w); flux_rpc_usecount_decr (rpc); }
/* Internal callback for matching response. * For the multi-response case, overwrite previous message if * flux_rpc_next () was not called. */ static void rpc_cb (flux_t *h, flux_msg_handler_t *w, const flux_msg_t *msg, void *arg) { flux_rpc_t *rpc = arg; assert (rpc->then_cb != NULL); flux_rpc_usecount_incr (rpc); if (rpc->rx_msg || rpc->rx_errnum) (void)flux_rpc_next (rpc); if (!(rpc->rx_msg = flux_msg_copy (msg, true))) goto done; rpc->rx_count++; rpc->then_cb (rpc, rpc->then_arg); done: if (rpc->rx_count >= rpc->rx_expected || flux_fatality (rpc->h)) flux_msg_handler_stop (rpc->w); flux_rpc_usecount_decr (rpc); }
void flux_rpc_destroy (flux_rpc_t *rpc) { int saved_errno = errno; flux_rpc_usecount_decr (rpc); errno = saved_errno; }
void flux_rpc_destroy (flux_rpc_t *rpc) { flux_rpc_usecount_decr (rpc); }