From 5a8c7a1803a7faf1f7571c9c287cf8f76469ee4d Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 13 Jul 2007 08:47:30 +0000 Subject: [PATCH] Slaves try a bit harder to connect to the master git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3756 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/gras/pmm/pmm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/examples/gras/pmm/pmm.c b/examples/gras/pmm/pmm.c index 969fe8500b..12bc56fad1 100755 --- a/examples/gras/pmm/pmm.c +++ b/examples/gras/pmm/pmm.c @@ -355,6 +355,7 @@ static int pmm_worker_cb(gras_msg_cb_ctx_t ctx, void *payload) { int slave(int argc,char *argv[]) { gras_socket_t mysock; gras_socket_t master; + int connected = 0; /* Init the GRAS's infrastructure */ gras_init(&argc, argv); @@ -366,9 +367,19 @@ int slave(int argc,char *argv[]) { /* Create the connexions */ mysock = gras_socket_server_range(3000,9999,0,0); - gras_os_sleep(1); /* let the master get ready */ - INFO1("Sensor starting (on port %d)",gras_os_myport()); - master = gras_socket_client_from_string(argv[1]); + INFO1("Sensor starting (on port %d)",gras_os_myport()); + while (!connected) { + xbt_ex_t e; + TRY { + master = gras_socket_client_from_string(argv[1]); + connected = 1; + } CATCH(e) { + if (e.category != system_error) + RETHROW; + xbt_ex_free(e); + gras_os_sleep(0.5); + } + } /* Join and run the group */ amok_pm_group_join(master,"pmm"); -- 2.20.1