Commit 98ea1181 authored by Philip Carns's avatar Philip Carns

use hg_handle_t directly in handlers

- the mercury hg_handle_t is really a pointer that references an
  internally defined structure, we can (and should, for proper
  reference counting purposes) pass it directly to ULTs without copying
- code using margo must be updated accordingly, handler ULT argument is
  an hg_handle_t now, not an hg_handle_t*
parent 2a8c6f6f
......@@ -20,7 +20,7 @@
static void my_rpc_ult(void *_arg)
{
hg_handle_t *handle = _arg;
hg_handle_t handle = _arg;
hg_return_t hret;
my_rpc_out_t out;
......@@ -36,7 +36,7 @@ static void my_rpc_ult(void *_arg)
#endif
margo_instance_id mid;
ret = HG_Get_input(*handle, &in);
ret = HG_Get_input(handle, &in);
assert(ret == HG_SUCCESS);
printf("Got RPC request with input_val: %d\n", in.input_val);
......@@ -48,7 +48,7 @@ static void my_rpc_ult(void *_arg)
assert(buffer);
/* register local target buffer for bulk access */
hgi = HG_Get_info(*handle);
hgi = HG_Get_info(handle);
assert(hgi);
ret = HG_Bulk_create(hgi->hg_class, 1, &buffer,
&size, HG_BULK_WRITE_ONLY, &bulk_handle);
......@@ -74,13 +74,12 @@ static void my_rpc_ult(void *_arg)
abt_io_close(aid, fd);
#endif
hret = HG_Respond(*handle, NULL, NULL, &out);
hret = HG_Respond(handle, NULL, NULL, &out);
assert(hret == HG_SUCCESS);
HG_Bulk_free(bulk_handle);
HG_Destroy(*handle);
HG_Destroy(handle);
free(buffer);
free(handle);
return;
}
......@@ -88,7 +87,7 @@ DEFINE_MARGO_RPC_HANDLER(my_rpc_ult)
static void my_rpc_shutdown_ult(void *_arg)
{
hg_handle_t *handle = _arg;
hg_handle_t handle = _arg;
hg_return_t hret;
struct hg_info *hgi;
......@@ -96,14 +95,14 @@ static void my_rpc_shutdown_ult(void *_arg)
printf("Got RPC request to shutdown\n");
hgi = HG_Get_info(*handle);
hgi = HG_Get_info(handle);
assert(hgi);
mid = margo_hg_class_to_instance(hgi->hg_class);
hret = margo_respond(mid, *handle, NULL);
hret = margo_respond(mid, handle, NULL);
assert(hret == HG_SUCCESS);
HG_Destroy(*handle);
HG_Destroy(handle);
/* NOTE: we assume that the server daemon is using
* margo_wait_for_finalize() to suspend until this RPC executes, so there
......
......@@ -180,13 +180,10 @@ hg_return_t __name##_handler(hg_handle_t handle) { \
ABT_pool* __pool; \
margo_instance_id __mid; \
struct hg_info *__hgi; \
hg_handle_t* __handle = (hg_handle_t*) malloc(sizeof(*__handle)); \
if(!__handle) return(HG_NOMEM_ERROR); \
*__handle = handle; \
__hgi = HG_Get_info(handle); \
__mid = margo_hg_class_to_instance(__hgi->hg_class); \
__pool = margo_get_handler_pool(__mid); \
__ret = ABT_thread_create(*__pool, __name, __handle, ABT_THREAD_ATTR_NULL, NULL); \
__ret = ABT_thread_create(*__pool, __name, handle, ABT_THREAD_ATTR_NULL, NULL); \
if(__ret != 0) { \
return(HG_NOMEM_ERROR); \
} \
......
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