- gras_msg_wait_ext(ctx->timeout,
- ctx->msgtype, NULL, msgfilter_rpcID, &ctx->ID,
- &received);
- free(ctx);
+ if (ctx->msgtype->answer_type) {
+ xbt_assert(answer,
+ "Answers to RPC '%s' convey a payload you must accept",
+ ctx->msgtype->name);
+ } else {
+ xbt_assert(!answer,
+ "No payload was declared for answers to RPC '%s'",
+ ctx->msgtype->name);
+ }
+
+ TRY {
+ /* The filter returns 1 when we eat an old RPC answer to something canceled */
+ do {
+ gras_msg_wait_ext_(ctx->timeout,
+ ctx->msgtype, NULL, msgfilter_rpcID, &ctx->ID,
+ &received);
+ } while (received.ID != ctx->ID);
+
+ }
+ CATCH(e) {
+ if (!_gras_rpc_cancelled)
+ _gras_rpc_cancelled = xbt_dynar_new(sizeof(ctx), NULL);
+ xbt_dynar_push(_gras_rpc_cancelled, &ctx);
+ XBT_INFO
+ ("canceled RPC %ld pushed onto the stack (%s from %s:%d) Reason: %s",
+ ctx->ID, ctx->msgtype->name,
+ gras_socket_peer_name(ctx->expeditor),
+ gras_socket_peer_port(ctx->expeditor), e.msg);
+ RETHROW;
+ }
+
+ xbt_mallocator_release(gras_msg_ctx_mallocator, ctx);