X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1c080fdf88d3dc8cbf7413b1f8b3ce66d475070a..4cc294f2d53a7d6201026a0bc975ca550d55ad64:/examples/gras/pmm/pmm.c diff --git a/examples/gras/pmm/pmm.c b/examples/gras/pmm/pmm.c index 969fe8500b..01fe32dda4 100755 --- a/examples/gras/pmm/pmm.c +++ b/examples/gras/pmm/pmm.c @@ -354,7 +354,8 @@ 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; + gras_socket_t master = NULL; + 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");