Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce the waiting time in RL on make check
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 13 Jul 2007 08:54:26 +0000 (08:54 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 13 Jul 2007 08:54:26 +0000 (08:54 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3758 48e7efb5-ca39-0410-a469-dd3cf9ba447f

examples/gras/ping/ping_client.c
examples/gras/ping/test_rl

index c496424..6230b70 100644 (file)
@@ -13,6 +13,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(Ping);
 int client(int argc,char *argv[]) {
   xbt_ex_t e; 
   gras_socket_t toserver=NULL; /* peer */
+  int connected = 0;
 
   gras_socket_t from;
   int ping, pong;
@@ -35,13 +36,20 @@ int client(int argc,char *argv[]) {
   gras_os_sleep(1);
    
   /* 4. Create a socket to speak to the server */
-  TRY {
-    toserver=gras_socket_client(host,port);
-  } CATCH(e) {
-    RETHROW0("Unable to connect to the server: %s");
+  while (!connected) {
+     TRY {
+       toserver=gras_socket_client(host,port);
+       connected = 1;
+     } CATCH(e) {
+       if (e.category != system_error)
+         /* dunno what happened, let the exception go through */
+         RETHROW0("Unable to connect to the server: %s");
+       xbt_ex_free(e);
+       gras_os_sleep(0.05);
+     }
   }
-  INFO2("Connected to %s:%d.",host,port);    
 
+  INFO2("Connected to %s:%d.",host,port);    
 
   /* 5. Register the messages. 
         See, it doesn't have to be done completely at the beginning, only before use */
index 41f4679..a36a84c 100755 (executable)
@@ -10,8 +10,6 @@
 > Done.
 > Exiting GRAS
 
-$ sleep 1
-
 #! set timeout 20
 & $SG_TEST_ENV ./ping_client$EXEEXT 127.0.0.1 4002 --log=root.fmt=%m%n
 > Launch client (server on 127.0.0.1:4002)