X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d84113e2eb8d578a6838d21f84f55d9e77c65d4..dcbef682c82dc36f62828f331ba4adc39d0324ea:/examples/msg/bittorrent/bittorrent.c diff --git a/examples/msg/bittorrent/bittorrent.c b/examples/msg/bittorrent/bittorrent.c index 367933000c..0ad478188e 100644 --- a/examples/msg/bittorrent/bittorrent.c +++ b/examples/msg/bittorrent/bittorrent.c @@ -1,17 +1,24 @@ -/* Copyright (c) 2012. The SimGrid Team. +/* Copyright (c) 2012-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "bittorrent.h" #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 +32,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_property_value(host, "stream", (char*)stream, NULL); + } + MSG_function_register("tracker", tracker); MSG_function_register("peer", peer); @@ -32,7 +48,11 @@ int main(int argc, char *argv[]) MSG_main(); - MSG_clean(); + xbt_dynar_foreach(host_list, i, host) { + RngStream stream = (RngStream) MSG_host_get_property_value(host, "stream"); + RngStream_DeleteStream(&stream); + } + xbt_dynar_free(&host_list); return 0; }