Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not push newly created sockets into the dynar before they get initialized, or...
[simgrid.git] / src / gras / Msg / rl_msg.c
index 50cf748..a4c4e16 100644 (file)
@@ -59,7 +59,10 @@ void gras_msg_send_ext(gras_socket_t   sock,
   if (kind == e_gras_msg_kind_rpcerror) {
      /* error on remote host, carfull, payload is an exception */
     gras_datadesc_send(sock, gras_datadesc_by_name("ex_t"),payload);
-  } else {
+  } else if (kind == e_gras_msg_kind_rpcanswer) {
+    if (msgtype->answer_type)
+      gras_datadesc_send(sock, msgtype->answer_type, payload);
+  }else {
      /* regular message */
      if (msgtype->ctn_type)
        gras_datadesc_send(sock, msgtype->ctn_type, payload);
@@ -146,6 +149,20 @@ gras_msg_recv(gras_socket_t    sock,
     msg->payl=xbt_malloc(msg->payl_size);
     gras_datadesc_recv(sock, gras_datadesc_by_name("ex_t"), r_arch, msg->payl);
 
+  } else if  (msg->kind == e_gras_msg_kind_rpcanswer) {
+     /* answer to RPC */
+     if (msg->type->answer_type) {
+       msg->payl_size=gras_datadesc_size(msg->type->answer_type);
+       xbt_assert2(msg->payl_size > 0,
+                   "%s %s",
+                   "Dynamic array as payload is forbided for now (FIXME?).",
+                   "Reference to dynamic array is allowed.");
+       msg->payl = xbt_malloc(msg->payl_size);
+       gras_datadesc_recv(sock, msg->type->answer_type, r_arch, msg->payl);
+     } else {
+       msg->payl = NULL;
+       msg->payl_size = 0;
+     }
   } else {
      /* regular message */
      if (msg->type->ctn_type) {