Commit 8a92d75b authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added functions to get the provider id and the address from a provider handle

parent 42b78cbc
......@@ -71,6 +71,23 @@ int bake_provider_handle_create(
*/
int bake_provider_handle_ref_incr(bake_provider_handle_t handle);
/**
* @brief Returns the address and provider id of a provider handle.
* The returned address should be freed by the caller using
* margo_addr_free.
*
* @param handle Provider handle
* @param mid Returned margo instance (ignored if NULL)
* @param addr Returned address (ignored if NULL)
* @param provider_id Returned provider id (ignored if NULL)
*
* @return BAKE_SUCCESS or corresponding error code.
*/
int bake_provider_get_info(bake_provider_handle_t handle,
margo_instance_id *mid,
hg_addr_t *addr,
uint16_t *provider_id);
/**
* Get the limit (in bytes) bellow which this provider handle will use
* eager mode (i.e. packing data into the RPC instead of using RDMA).
......
......@@ -389,7 +389,6 @@ class provider_handle {
friend class client;
bake_provider_handle_t m_ph = BAKE_PROVIDER_HANDLE_NULL;
uint16_t m_provider_id;
public:
......@@ -480,7 +479,21 @@ class provider_handle {
* @brief Returns the provider id.
*/
uint16_t provider_id() const {
return m_provider_id;
uint16_t result;
int ret = bake_provider_handle_get_info(m_ph, NULL, NULL, &result);
_CHECK_RET(ret);
return result;
}
/**
* @brief Returns the address of the provider handle.
* It is up to the caller to free the returned address.
*/
hg_addr_t address() const {
hg_addr_t addr = HG_ADDR_NULL;
int ret = bake_provider_handle_get_info(m_ph, NULL, &addr, NULL);
_CHECK_RET(ret);
return addr;
}
/**
......
......@@ -269,6 +269,22 @@ int bake_provider_handle_ref_incr(bake_provider_handle_t handle)
return BAKE_SUCCESS;
}
int bake_provider_get_info(bake_provider_handle_t handle,
margo_instance_id *mid,
hg_addr_t *addr,
uint16_t *provider_id)
{
int ret = BAKE_SUCCESS;
hg_return_t hret = HG_SUCCESS;
if(handle == BAKE_PROVIDER_HANDLE_NULL) return BAKE_ERR_INVALID_ARG;
if(mid) *mid = handle->mid;
if(addr) hret = margo_addr_dup(handle->mid, handle->addr, addr);
if(provider_id) *provider_id = handle->provider_id;
if(hret != HG_SUCCESS)
ret = BAKE_ERR_MERCURY;
return ret;
}
int bake_provider_handle_release(bake_provider_handle_t handle)
{
if(handle == BAKE_PROVIDER_HANDLE_NULL) return BAKE_ERR_INVALID_ARG;
......
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