Commit 1846e73e authored by Matthieu Dorier's avatar Matthieu Dorier

corrected throw from MARGO_ASSERT

parent 39d3a137
......@@ -203,7 +203,7 @@ public:
~bulk() {
if(m_bulk != HG_BULK_NULL) {
hg_return_t ret = margo_bulk_free(m_bulk);
MARGO_ASSERT(ret, margo_bulk_free);
MARGO_ASSERT_TERMINATE(ret, margo_bulk_free, -1);
}
}
......
......@@ -151,7 +151,7 @@ public:
~callable_remote_procedure() {
if(m_handle != HG_HANDLE_NULL) {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT(ret, margo_destroy);
MARGO_ASSERT_TERMINATE(ret, margo_destroy, -1);
}
}
......
......@@ -92,8 +92,11 @@ private:
static void rpc_handler_ult(hg_handle_t handle) {
using G = typename std::remove_reference<F>::type;
const struct hg_info* info = margo_get_info(handle);
THALLIUM_ASSERT_CONDITION(info != nullptr, "margo_get_info returned null");
margo_instance_id mid = margo_hg_handle_get_instance(handle);
THALLIUM_ASSERT_CONDITION(mid != 0, "margo_hg_handle_get_instance returned null");
void* data = margo_registered_data(mid, info->id);
THALLIUM_ASSERT_CONDITION(data != nullptr, "margo_registered_data returned null");
auto cb_data = static_cast<rpc_callback_data*>(data);
auto f = function_cast<G>(cb_data->m_function);
request req(*(cb_data->m_engine), handle, disable_response);
......@@ -130,6 +133,7 @@ private:
ret = ABT_thread_create(pool, (void (*)(void *)) rpc_handler_ult<F,disable_response>,
handle, ABT_THREAD_ATTR_NULL, NULL);
if(ret != 0) {
margo_destroy(handle);
return HG_NOMEM_ERROR;
}
return HG_SUCCESS;
......
......@@ -6,6 +6,7 @@
#ifndef __THALLIUM_MARGO_EXCEPTION_HPP
#define __THALLIUM_MARGO_EXCEPTION_HPP
#include <iostream>
#include <exception>
#include <stdexcept>
#include <string>
......@@ -53,16 +54,35 @@ std::string translate_margo_error_code(hg_return_t ret);
#define MARGO_THROW(__fun__,__msg__) do {\
throw margo_exception(#__fun__,__FILE__,__LINE__,__msg__); \
} while(0);
} while(0)
#define MARGO_ASSERT(__ret__, __fun__) do {\
if(__ret__ != HG_SUCCESS) { \
std::stringstream msg; \
msg << "Function returned "; \
msg << translate_margo_error_code(__ret__); \
MARGO_THROW(__fun__, msg.str()); \
}\
} while(0);
} while(0)
#define MARGO_ASSERT_TERMINATE(__ret__, __fun__, __failcode__) do {\
if(__ret__ != HG_SUCCESS) { \
std::stringstream msg; \
msg << "Function returned "; \
msg << translate_margo_error_code(__ret__); \
std::cerr << #__fun__ << ":" << __FILE__ << ":" << __LINE__ << ": " << msg.str(); \
exit(__failcode__);\
}\
} while(0)
#define THALLIUM_ASSERT_CONDITION(__cond__, __msg__) do {\
if(!(__cond__)) { \
std::stringstream msg; \
msg << "Condition " << #__cond__ << " failed (" << __FILE__ << __LINE__ \
<< ", " << __msg__; \
throw std::runtime_error(msg.str()); \
}\
} while(0)
}
#endif
......@@ -97,7 +97,7 @@ public:
*/
~request() {
hg_return_t ret = margo_destroy(m_handle);
MARGO_ASSERT(ret, margo_destroy);
MARGO_ASSERT_TERMINATE(ret, margo_destroy, -1);
}
/**
......
......@@ -61,7 +61,7 @@ endpoint& endpoint::operator=(endpoint&& other) {
endpoint::~endpoint() {
if(m_addr != HG_ADDR_NULL) {
hg_return_t ret = margo_addr_free(m_engine->m_mid, m_addr);
MARGO_ASSERT(ret, margo_addr_free);
MARGO_ASSERT_TERMINATE(ret, margo_addr_free, -1);
}
}
......
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