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