Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use flush when needed, load the right _interfaces, be more verbose when we get an...
[simgrid.git] / src / gras / Msg / msg.c
index 91d5aca..6e6bf80 100644 (file)
@@ -9,6 +9,9 @@
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "Msg/msg_private.h"
+#include "DataDesc/datadesc_interface.h"
+#include "Transport/transport_interface.h" /* gras_trp_chunk_send/recv */
+#include "Virtu/virtu_interface.h"
 
 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(msg,GRAS);
 
@@ -145,7 +148,7 @@ gras_msgtype_declare_v(const char            *name,
   msgtype->name_len = strlen(namev);
   msgtype->version = version;
   msgtype->ctn_type = payload;
-  gras_datadesc_ref(payload);
+  gras_datadesc_addref(payload);
 
   TRY(gras_set_add(_gras_msgtype_set, (gras_set_elm_t*)msgtype,
                   &gras_msgtype_free));
@@ -201,12 +204,13 @@ gras_msg_send(gras_socket_t  *sock,
     gras_assert(string_type);
   }
 
-  DEBUG3("send %s to %s:%d", msgtype->name, 
+  DEBUG3("send '%s' to %s:%d", msgtype->name, 
         gras_socket_peer_name(sock),gras_socket_peer_port(sock));
   TRY(gras_trp_chunk_send(sock, GRAS_header, 6));
 
   TRY(gras_datadesc_send(sock, string_type,   &msgtype->name));
   TRY(gras_datadesc_send(sock, msgtype->ctn_type, payload));
+  TRY(gras_trp_flush(sock));
 
   return no_error;
 }
@@ -245,8 +249,13 @@ gras_msg_recv(gras_socket_t   *sock,
         (int)header[4],gras_datadesc_arch_name(r_arch));
 
   TRY(gras_datadesc_recv(sock, string_type, r_arch, &msg_name));
-  TRY(gras_set_get_by_name(_gras_msgtype_set,
-                          msg_name,(gras_set_elm_t**)msgtype));
+  errcode = gras_set_get_by_name(_gras_msgtype_set,
+                                msg_name,(gras_set_elm_t**)msgtype);
+  if (errcode != no_error)
+    RAISE2(errcode,
+          "Got error %s while retrieving the type associated to messages '%s'",
+          gras_error_name(errcode),msg_name);
+  /* FIXME: Survive unknown messages */
   free(msg_name);
 
   *payload_size=gras_datadesc_size((*msgtype)->ctn_type);