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 d98c40f..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);