X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0afab0e550e09d35a4aaaae802c7f2ea17d2b860..badfaf9202e51461e7a685e17ce982ea34ad219a:/examples/msg/bittorrent/bittorrent.c diff --git a/examples/msg/bittorrent/bittorrent.c b/examples/msg/bittorrent/bittorrent.c index e0e4c68689..741cd2c74f 100644 --- a/examples/msg/bittorrent/bittorrent.c +++ b/examples/msg/bittorrent/bittorrent.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012. The SimGrid Team. +/* Copyright (c) 2012-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -7,11 +7,17 @@ #include "peer.h" #include "tracker.h" #include +#include + /** * Bittorrent example launcher */ int main(int argc, char *argv[]) { + xbt_dynar_t host_list; + msg_host_t host; + unsigned i; + MSG_init(&argc, argv); /* Check the arguments */ @@ -25,6 +31,15 @@ int main(int argc, char *argv[]) MSG_create_environment(platform_file); + host_list = MSG_hosts_as_dynar(); + xbt_dynar_foreach(host_list, i, host) { + char descr[512]; + RngStream stream; + snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host)); + stream = RngStream_CreateStream(descr); + MSG_host_set_data(host, stream); + } + MSG_function_register("tracker", tracker); MSG_function_register("peer", peer); @@ -32,5 +47,11 @@ int main(int argc, char *argv[]) MSG_main(); + xbt_dynar_foreach(host_list, i, host) { + RngStream stream = MSG_host_get_data(host); + RngStream_DeleteStream(&stream); + } + xbt_dynar_free(&host_list); + return 0; }