Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Now that MSG uses sain units, we don't have to convert anymore
[simgrid.git] / src / gras / Msg / rpc.c
index 85d30d2..79a0d12 100644 (file)
@@ -9,11 +9,9 @@
 
 #include "gras/Msg/msg_private.h"
                 
-//XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_rpc,gras_msg,"RPCing");
-
 xbt_set_t _gras_rpctype_set = NULL;
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_rpc,gras_msg,"RPC mecanism");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_msg_rpc,gras_msg,"RPC mecanism");
 
 
 /** @brief declare a new versionned RPC type of the given name and payloads
@@ -84,6 +82,16 @@ gras_msg_rpc_async_call(gras_socket_t server,
                        void *request) {
   gras_msg_cb_ctx_t ctx = xbt_new0(s_gras_msg_cb_ctx_t,1);
 
+  if (msgtype->ctn_type) {
+    xbt_assert1(request,
+               "RPC type '%s' convey a payload you must provide",
+               msgtype->name);
+  } else {
+    xbt_assert1(!request,
+               "No payload was declared for RPC type '%s'",
+               msgtype->name);
+  }
+
   ctx->ID = last_msg_ID++;
   ctx->expeditor = server;
   ctx->msgtype=msgtype;
@@ -105,6 +113,16 @@ void gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx,
                             void *answer) {
   s_gras_msg_t received;
 
+  if (ctx->msgtype->answer_type) {
+    xbt_assert1(answer,
+               "Answers to RPC '%s' convey a payload you must accept",
+               ctx->msgtype->name);
+  } else {
+    xbt_assert1(!answer,
+               "No payload was declared for answers to RPC '%s'",
+               ctx->msgtype->name);
+  }
+
   gras_msg_wait_ext(ctx->timeout,
                    ctx->msgtype, NULL, msgfilter_rpcID, &ctx->ID,
                    &received);
@@ -121,6 +139,7 @@ void gras_msg_rpc_async_wait(gras_msg_cb_ctx_t ctx,
      __xbt_ex_ctx()->ctx_ex.remote   = 1;
      __xbt_ex_ctx()->ctx_ex.host     = e.host;
      __xbt_ex_ctx()->ctx_ex.procname = e.procname;
+     __xbt_ex_ctx()->ctx_ex.pid      = e.pid;
      __xbt_ex_ctx()->ctx_ex.file     = e.file;
      __xbt_ex_ctx()->ctx_ex.line     = e.line;
      __xbt_ex_ctx()->ctx_ex.func     = e.func;