Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give peer a chance to get the message before closing the socket
[simgrid.git] / examples / gras / rpc / rpc.c
index 3805fc9..94fe661 100644 (file)
@@ -53,7 +53,7 @@ static void exception_catching(void) {
     xbt_assert1(!strncmp(e.msg,"Some error we will catch on client side",
                         strlen("Some error we will catch on client side")), 
                "Got wrong message: %s", e.msg);
-    xbt_ex_free(&e);
+    xbt_ex_free(e);
   }
 }
 
@@ -63,11 +63,11 @@ static void exception_catching(void) {
 
 
 int client(int argc,char *argv[]) {
-  xbt_ex_t e; 
+  xbt_ex_t e;
   gras_socket_t toserver=NULL; /* peer */
   gras_socket_t toforwarder=NULL; /* peer */
 
-  
+  memset(&e,0,sizeof(xbt_ex_t));
 
   int ping, pong, i;
   volatile int gotit=0;
@@ -144,7 +144,7 @@ int client(int argc,char *argv[]) {
                         strlen("Some error we will catch on client side")), 
                "Got wrong message: %s", e.msg);
     INFO0("Got the expected exception when calling the exception raising RPC");
-    xbt_ex_free(&e);
+    xbt_ex_free(e);
   }
 
   if (!gotit)
@@ -162,7 +162,7 @@ int client(int argc,char *argv[]) {
                         gras_msgtype_by_name("raise exception"), NULL, NULL);
      } CATCH(e) {
        gotit = 1;
-       xbt_ex_free(&e);
+       xbt_ex_free(e);
      }
      if (!gotit) {
        THROW0(unknown_error,0,"Didn't got the remote exception!");
@@ -190,12 +190,13 @@ int client(int argc,char *argv[]) {
                "Got wrong category: %d (instead of %d)", 
                e.category,unknown_error);
     INFO0("Got the expected exception when calling the exception raising RPC");
-    xbt_ex_free(&e);
+    xbt_ex_free(e);
     exception_catching();
   }
   
   gras_msg_send(toserver,gras_msgtype_by_name("kill"),NULL);
   gras_msg_send(toforwarder,gras_msgtype_by_name("kill"),NULL);
+  gras_os_sleep(1); /* give peer a chance to get the message before closing the socket */
 
   /* 11. Cleanup the place before leaving */
   gras_socket_close(toserver);
@@ -345,8 +346,10 @@ int server (int argc,char *argv[]) {
 
   /* 5. Wait for the ping incomming messages */
   
-  /* BUG: if the server is gone before the forwarder tries to connect, 
-     it dies awfully with :
+  /** \bug if the server is gone before the forwarder tries to connect, 
+     it dies awfully with the following message. The problem stands somewhere
+     at the interface between the gras_socket_t and the msg mess. There is thus
+     no way for me to dive into this before this interface is rewritten 
 ==15875== Invalid read of size 4
 ==15875==    at 0x408B805: find_port (transport_plugin_sg.c:68)
 ==15875==    by 0x408BD64: gras_trp_sg_socket_client (transport_plugin_sg.c:115)