Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SIGURS1 is not defined on windows (but signal() and signal.h are both here)
[simgrid.git] / examples / gras / rpc / rpc.c
index 3805fc9..66c1b2e 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,14 @@ 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);
+
+  INFO2("Ask %s:%d to die",gras_socket_peer_name(toforwarder),gras_socket_peer_port(toforwarder));
   gras_msg_send(toforwarder,gras_msgtype_by_name("kill"),NULL);
+  INFO2("Ask %s:%d to die",gras_socket_peer_name(toserver),gras_socket_peer_port(toserver));
+  gras_msg_send(toserver,gras_msgtype_by_name("kill"),NULL);
 
   /* 11. Cleanup the place before leaving */
   gras_socket_close(toserver);
@@ -216,6 +218,8 @@ typedef struct {
 
 static int forwarder_cb_kill(gras_msg_cb_ctx_t ctx,
                             void             *payload_data) {
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  INFO2("Asked to die by %s:%d",gras_socket_peer_name(expeditor),gras_socket_peer_port(expeditor));
   forward_data_t fdata=gras_userdata_get();
   fdata->done = 1;
   return 1;
@@ -225,6 +229,7 @@ static int forwarder_cb_forward_ex(gras_msg_cb_ctx_t ctx,
                                   void             *payload_data) {
   forward_data_t fdata=gras_userdata_get();
 
+  INFO0("Forward a request");
   gras_msg_rpccall(fdata->server, 60,
                   gras_msgtype_by_name("raise exception"),NULL,NULL);
   return 1;
@@ -277,6 +282,9 @@ typedef struct {
 
 static int server_cb_kill(gras_msg_cb_ctx_t ctx,
                          void             *payload_data) {
+  gras_socket_t expeditor = gras_msg_cb_ctx_from(ctx);
+  INFO2("Asked to die by %s:%d",gras_socket_peer_name(expeditor),gras_socket_peer_port(expeditor));
+
   server_data_t sdata=gras_userdata_get();
   sdata->done = 1;
   return 1;
@@ -345,8 +353,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)