Commit a0799a63 authored by Philip Carns's avatar Philip Carns

fix lookup function and test

parent 78688cfd
......@@ -213,7 +213,7 @@ static void run_my_rpc(void *_arg)
sprintf((char*)buffer, "Hello world!\n");
/* find addr for server */
ret = NA_Addr_lookup_wait(arg->network_class, "tcp://localhost:1234", &svr_addr);
ret = margo_na_addr_lookup(arg->mid, arg->network_class, arg->na_context, "tcp://localhost:1234", &svr_addr);
assert(ret == 0);
/* create handle */
......
......@@ -89,7 +89,8 @@ na_return_t margo_na_addr_lookup(
margo_instance_id mid,
na_class_t *na_class,
na_context_t *context,
const char *name);
const char *name,
na_addr_t *addr);
/**
* Retrive the Margo instance that has been associated with a Mercury class
......
......@@ -167,16 +167,6 @@ hg_return_t margo_forward(
return(hret);
}
static na_return_t margo_na_addr_lookup_cb(const struct na_cb_info *callback_info)
{
na_return_t nret = callback_info->ret;
ABT_eventual *eventual = callback_info->arg;
/* propagate return code out through eventual */
ABT_eventual_set(*eventual, &nret, sizeof(nret));
return(NA_SUCCESS);
}
static hg_return_t margo_bulk_transfer_cb(const struct hg_bulk_cb_info *hg_bulk_cb_info)
{
......@@ -189,18 +179,40 @@ static hg_return_t margo_bulk_transfer_cb(const struct hg_bulk_cb_info *hg_bulk_
return(HG_SUCCESS);
}
struct lookup_cb_evt
{
na_return_t nret;
na_addr_t addr;
};
static na_return_t margo_na_addr_lookup_cb(const struct na_cb_info *callback_info)
{
struct lookup_cb_evt evt;
evt.nret = callback_info->ret;
evt.addr = callback_info->info.lookup.addr;
ABT_eventual *eventual = callback_info->arg;
/* propagate return code out through eventual */
ABT_eventual_set(*eventual, &evt, sizeof(evt));
return(NA_SUCCESS);
}
na_return_t margo_na_addr_lookup(
margo_instance_id mid,
na_class_t *na_class,
na_context_t *context,
const char *name)
const char *name,
na_addr_t *addr)
{
na_return_t nret;
na_return_t *waited_nret;
struct lookup_cb_evt *evt;
ABT_eventual eventual;
int ret;
ret = ABT_eventual_create(sizeof(nret), &eventual);
ret = ABT_eventual_create(sizeof(*evt), &eventual);
if(ret != 0)
{
return(HG_NOMEM_ERROR);
......@@ -210,8 +222,9 @@ na_return_t margo_na_addr_lookup(
&eventual, name, NA_OP_ID_IGNORE);
if(nret == 0)
{
ABT_eventual_wait(eventual, (void**)&waited_nret);
nret = *waited_nret;
ABT_eventual_wait(eventual, (void**)&evt);
*addr = evt->addr;
nret = evt->nret;
}
ABT_eventual_free(&eventual);
......
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