Commit d3132d64 authored by Philip Carns's avatar Philip Carns

implement mplex registration fn

parent 10c569c3
......@@ -134,11 +134,7 @@ int svc1_register(margo_instance_id mid, ABT_pool pool, uint32_t mplex_id)
return(ret);
}
/* TODO: for each function:
* - register with margo
* - this will put into hash table in mid that can map <id,mplex_id> to
* <pool>, checking for duplicate first
*
/* TODO:
* - elsewhere:
* - new variant of DEFINE_MARGO_RPC_HANDLER that:
* - looks up registered margo thing
......
......@@ -16,9 +16,23 @@
#include "margo.h"
#include "margo-timer.h"
#include "utlist.h"
#include "uthash.h"
#define MERCURY_PROGRESS_TIMEOUT_UB 100 /* 100 milliseconds */
struct mplex_key
{
hg_id_t id;
uint32_t mplex_id;
};
struct mplex_element
{
struct mplex_key key;
ABT_pool pool;
UT_hash_handle hh;
};
struct margo_instance
{
/* provided by caller */
......@@ -43,6 +57,9 @@ struct margo_instance
ABT_cond finalize_cond;
int table_index;
/* hash table to track multiplexed rpcs registered with margo */
struct mplex_element *mplex_table;
};
struct margo_handler_mapping
......@@ -787,5 +804,24 @@ static int margo_xstream_is_in_progress_pool(margo_instance_id mid)
int margo_register_mplex(margo_instance_id mid, hg_id_t id, uint32_t mplex_id, ABT_pool pool)
{
return(-1);
struct mplex_key key;
struct mplex_element *element;
memset(&key, 0, sizeof(key));
key.id = id;
key.mplex_id = mplex_id;
HASH_FIND(hh, mid->mplex_table, &key, sizeof(key), element);
if(element)
return(0);
element = malloc(sizeof(*element));
if(!element)
return(-1);
element->key = key;
element->pool = pool;
HASH_ADD(hh, mid->mplex_table, key, sizeof(key), element);
return(0);
}
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