X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/314b9881b1714c0a3f52dbb45c02e0bdb31c57da..2b859d7b5c2aed26d77af4b362ba4f3d39626a9a:/examples/msg/chainsend/peer.c diff --git a/examples/msg/chainsend/peer.c b/examples/msg/chainsend/peer.c index 1827df869c..927517565b 100644 --- a/examples/msg/chainsend/peer.c +++ b/examples/msg/chainsend/peer.c @@ -104,17 +104,22 @@ void peer_init(peer_t p, int argc, char *argv[]) void peer_shutdown(peer_t p) { - float start_time = MSG_get_clock(); - float end_time = start_time + PEER_SHUTDOWN_DEADLINE; + unsigned int size = xbt_dynar_length(p->pending_sends); + unsigned int idx; + msg_comm_t *comms = xbt_new(msg_comm_t, size); + + for (idx = 0; idx < size; idx++) { + comms[idx] = xbt_dynar_get_as(p->pending_sends, idx, msg_comm_t); + } XBT_DEBUG("Waiting for sends to finish before shutdown..."); - /* MSG_comm_waitall(p->pending_sends, PEER_SHUTDOWN_DEADLINE); FIXME: this doesn't work */ - while (xbt_dynar_length(p->pending_sends) && MSG_get_clock() < end_time) { - process_pending_connections(p->pending_sends); - MSG_process_sleep(1); + MSG_comm_waitall(comms, size, PEER_SHUTDOWN_DEADLINE); + + for (idx = 0; idx < size; idx++) { + MSG_comm_destroy(comms[idx]); } - xbt_assert(xbt_dynar_length(p->pending_sends) == 0, "Shutdown failed, sends still pending after deadline"); + xbt_free(comms); } void peer_delete(peer_t p)