return res;
}
+/* Mallocator cruft */
+xbt_mallocator_t gras_msg_ctx_mallocator = NULL;
+void* gras_msg_ctx_mallocator_new_f(void) {
+ return xbt_new0(s_gras_msg_cb_ctx_t,1);
+}
+void gras_msg_ctx_mallocator_free_f(void* ctx) {
+ xbt_free(ctx);
+}
+void gras_msg_ctx_mallocator_reset_f(void* ctx) {
+ memset(ctx, sizeof(s_gras_msg_cb_ctx_t),0);
+}
+
/** @brief Launch a RPC call, but do not block for the answer */
gras_msg_cb_ctx_t
gras_msg_rpc_async_call(gras_socket_t server,
double timeOut,
gras_msgtype_t msgtype,
void *request) {
- gras_msg_cb_ctx_t ctx = xbt_new0(s_gras_msg_cb_ctx_t,1);
+ gras_msg_cb_ctx_t ctx = xbt_mallocator_get(gras_msg_ctx_mallocator);
if (msgtype->ctn_type) {
xbt_assert1(request,
RETHROW;
}
- free(ctx);
+ xbt_mallocator_release(gras_msg_ctx_mallocator, ctx);
if (received.kind == e_gras_msg_kind_rpcerror) {
xbt_ex_t e;
memcpy(&e,received.payl,received.payl_size);
*/
void gras_msg_rpcreturn(double timeOut,gras_msg_cb_ctx_t ctx,void *answer) {
+ xbt_assert0(ctx->answer_due,
+ "RPC return not allowed here. Either not a RPC message or already returned a result");
+ ctx->answer_due = 0;
DEBUG5("Return to RPC '%s' from %s:%d (tOut=%f, payl=%p)",
ctx->msgtype->name,
gras_socket_peer_name(ctx->expeditor),gras_socket_peer_port(ctx->expeditor),