Commit d3132d64 authored by Philip Carns's avatar Philip Carns
Browse files

implement mplex registration fn

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