Commit 31ecc7ee authored by Jonathan Jenkins's avatar Jonathan Jenkins

wrapped HG_Respond

parent 2cdc9566
......@@ -100,9 +100,9 @@ static void my_rpc_shutdown_ult(void *_arg)
assert(hgi);
mid = margo_hg_class_to_instance(hgi->hg_class);
hret = HG_Respond(*handle, NULL, NULL, NULL);
hret = margo_respond(mid, *handle, NULL);
assert(hret == HG_SUCCESS);
HG_Destroy(*handle);
/* NOTE: we assume that the server daemon is using
......
......@@ -71,6 +71,24 @@ hg_return_t margo_forward(
hg_handle_t handle,
void *in_struct);
/**
* Send an RPC response, waiting for completion before returning
* control to the calling ULT.
* Note: this call is typically not needed as RPC listeners need not concern
* themselves with what happens after an RPC finishes. However, there are cases
* when this is useful (deferring resource cleanup, calling margo_finalize()
* for e.g. a shutdown RPC).
* @param [in] mid Margo instance
* @param [in] handle identifier for the RPC for which a response is being
* sent
* @param [in] out_struct output argument struct for response
* @return HG_SUCCESS on success, hg_return_t values on error. See HG_Respond.
*/
hg_return_t margo_respond(
margo_instance_id mid,
hg_handle_t handle,
void *out_struct);
/**
* Perform a bulk transfer
* @param [in] mid Margo instance
......
......@@ -205,7 +205,7 @@ ABT_pool* margo_get_handler_pool(margo_instance_id mid)
return(&mid->handler_pool);
}
static hg_return_t margo_forward_cb(const struct hg_cb_info *info)
static hg_return_t margo_cb(const struct hg_cb_info *info)
{
hg_return_t hret = info->ret;
......@@ -232,7 +232,35 @@ hg_return_t margo_forward(
return(HG_NOMEM_ERROR);
}
hret = HG_Forward(handle, margo_forward_cb, &eventual, in_struct);
hret = HG_Forward(handle, margo_cb, &eventual, in_struct);
if(hret == 0)
{
ABT_eventual_wait(eventual, (void**)&waited_hret);
hret = *waited_hret;
}
ABT_eventual_free(&eventual);
return(hret);
}
hg_return_t margo_respond(
margo_instance_id mid,
hg_handle_t handle,
void *out_struct)
{
hg_return_t hret = HG_TIMEOUT;
ABT_eventual eventual;
int ret;
hg_return_t* waited_hret;
ret = ABT_eventual_create(sizeof(hret), &eventual);
if(ret != 0)
{
return(HG_NOMEM_ERROR);
}
hret = HG_Respond(handle, margo_cb, &eventual, out_struct);
if(hret == 0)
{
ABT_eventual_wait(eventual, (void**)&waited_hret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment