Commit b6420b1a authored by Matthieu Dorier's avatar Matthieu Dorier

modified margo_get_handler_pool to prevent users from changing pool

parent 84581e51
...@@ -56,7 +56,7 @@ int main(int argc, char **argv) ...@@ -56,7 +56,7 @@ int main(int argc, char **argv)
hg_addr_t addr_self; hg_addr_t addr_self;
char addr_self_string[128]; char addr_self_string[128];
hg_size_t addr_self_string_sz = 128; hg_size_t addr_self_string_sz = 128;
ABT_pool *handler_pool; ABT_pool handler_pool;
char* svc_list; char* svc_list;
char* svc; char* svc;
...@@ -109,17 +109,17 @@ int main(int argc, char **argv) ...@@ -109,17 +109,17 @@ int main(int argc, char **argv)
*/ */
MARGO_REGISTER(mid, "my_shutdown_rpc", void, void, my_rpc_shutdown_ult); MARGO_REGISTER(mid, "my_shutdown_rpc", void, void, my_rpc_shutdown_ult);
handler_pool = margo_get_handler_pool(mid); margo_get_handler_pool(mid, &handler_pool);
svc = strtok(svc_list, ","); svc = strtok(svc_list, ",");
while(svc) while(svc)
{ {
if(!strcmp(svc, "data-xfer")) if(!strcmp(svc, "data-xfer"))
{ {
data_xfer_service_register(mid, *handler_pool, 0); data_xfer_service_register(mid, handler_pool, 0);
} }
else if(!strcmp(svc, "delegator")) else if(!strcmp(svc, "delegator"))
{ {
delegator_service_register(mid, *handler_pool, 0); delegator_service_register(mid, handler_pool, 0);
} }
else else
assert(0); assert(0);
......
...@@ -59,7 +59,7 @@ int main(int argc, char **argv) ...@@ -59,7 +59,7 @@ int main(int argc, char **argv)
hg_size_t addr_self_string_sz = 128; hg_size_t addr_self_string_sz = 128;
ABT_xstream svc1_xstream2; ABT_xstream svc1_xstream2;
ABT_pool svc1_pool2; ABT_pool svc1_pool2;
ABT_pool *handler_pool; ABT_pool handler_pool;
if(argc != 2) if(argc != 2)
{ {
...@@ -110,8 +110,8 @@ int main(int argc, char **argv) ...@@ -110,8 +110,8 @@ int main(int argc, char **argv)
/* register svc1, with mplex_id 1, to execute on the default handler pool /* register svc1, with mplex_id 1, to execute on the default handler pool
* used by Margo * used by Margo
*/ */
handler_pool = margo_get_handler_pool(mid); margo_get_handler_pool(mid, &handler_pool);
ret = svc1_register(mid, *handler_pool, 1); ret = svc1_register(mid, handler_pool, 1);
assert(ret == 0); assert(ret == 0);
/* create a dedicated xstream and pool for another instance of svc1 */ /* create a dedicated xstream and pool for another instance of svc1 */
...@@ -134,8 +134,8 @@ int main(int argc, char **argv) ...@@ -134,8 +134,8 @@ int main(int argc, char **argv)
/* register svc2, with mplex_id 3, to execute on the default handler pool /* register svc2, with mplex_id 3, to execute on the default handler pool
* used by Margo * used by Margo
*/ */
handler_pool = margo_get_handler_pool(mid); margo_get_handler_pool(mid, &handler_pool);
ret = svc2_register(mid, *handler_pool, 3); ret = svc2_register(mid, handler_pool, 3);
assert(ret == 0); assert(ret == 0);
/* shut things down */ /* shut things down */
......
...@@ -711,8 +711,10 @@ void margo_thread_sleep( ...@@ -711,8 +711,10 @@ void margo_thread_sleep(
* Retrieve the abt_handler pool that was associated with the instance at * Retrieve the abt_handler pool that was associated with the instance at
* initialization time * initialization time
* @param [in] mid Margo instance * @param [in] mid Margo instance
* @param [out] pool handler pool
* @return 0 on success, error code on failure
*/ */
ABT_pool* margo_get_handler_pool(margo_instance_id mid); int margo_get_handler_pool(margo_instance_id mid, ABT_pool* pool);
/** /**
* Retrieve the Mercury context that was associated with this instance at * Retrieve the Mercury context that was associated with this instance at
...@@ -836,7 +838,7 @@ hg_return_t __name##_handler(hg_handle_t handle) { \ ...@@ -836,7 +838,7 @@ hg_return_t __name##_handler(hg_handle_t handle) { \
return(HG_INVALID_PARAM); \ return(HG_INVALID_PARAM); \
}\ }\
if(__pool == ABT_POOL_NULL) \ if(__pool == ABT_POOL_NULL) \
__pool = *margo_get_handler_pool(__mid); \ margo_get_handler_pool(__mid, &__pool); \
__ret = ABT_thread_create(__pool, (void (*)(void *))__name, handle, ABT_THREAD_ATTR_NULL, NULL); \ __ret = ABT_thread_create(__pool, (void (*)(void *))__name, handle, ABT_THREAD_ATTR_NULL, NULL); \
if(__ret != 0) { \ if(__ret != 0) { \
return(HG_NOMEM_ERROR); \ return(HG_NOMEM_ERROR); \
......
...@@ -142,7 +142,7 @@ void margo_check_timers( ...@@ -142,7 +142,7 @@ void margo_check_timers(
int ret; int ret;
margo_timer_t *cur; margo_timer_t *cur;
struct margo_timer_instance *timer_inst; struct margo_timer_instance *timer_inst;
ABT_pool *handler_pool; ABT_pool handler_pool;
double now = ABT_get_wtime(); double now = ABT_get_wtime();
timer_inst = margo_get_timer_instance(mid); timer_inst = margo_get_timer_instance(mid);
...@@ -160,10 +160,10 @@ void margo_check_timers( ...@@ -160,10 +160,10 @@ void margo_check_timers(
cur->prev = cur->next = NULL; cur->prev = cur->next = NULL;
/* schedule callback on the handler pool */ /* schedule callback on the handler pool */
handler_pool = margo_get_handler_pool(mid); margo_get_handler_pool(mid, &handler_pool);
if(*handler_pool != ABT_POOL_NULL) if(handler_pool != ABT_POOL_NULL)
{ {
ret = ABT_thread_create(*handler_pool, cur->cb_fn, cur->cb_dat, ret = ABT_thread_create(handler_pool, cur->cb_fn, cur->cb_dat,
ABT_THREAD_ATTR_NULL, NULL); ABT_THREAD_ATTR_NULL, NULL);
assert(ret == ABT_SUCCESS); assert(ret == ABT_SUCCESS);
} }
......
...@@ -966,9 +966,14 @@ void margo_thread_sleep( ...@@ -966,9 +966,14 @@ void margo_thread_sleep(
return; return;
} }
ABT_pool* margo_get_handler_pool(margo_instance_id mid) int margo_get_handler_pool(margo_instance_id mid, ABT_pool* pool)
{ {
return(&mid->handler_pool); if(mid) {
*pool = mid->handler_pool;
return 0;
} else {
return -1;
}
} }
hg_context_t* margo_get_context(margo_instance_id mid) hg_context_t* margo_get_context(margo_instance_id mid)
......
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