From 3031d855f96e457fd7bf25e90c10440a39747567 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 4 Dec 2016 18:49:40 +0100 Subject: [PATCH] Don't store raw objects as host properties, which must be strings --- examples/msg/app-bittorrent/bittorrent.c | 8 ++++---- examples/msg/app-bittorrent/peer.c | 2 +- examples/msg/app-bittorrent/tracker.c | 2 +- examples/msg/dht-chord/dht-chord.c | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/msg/app-bittorrent/bittorrent.c b/examples/msg/app-bittorrent/bittorrent.c index b469d4ea82..c88b708e5b 100644 --- a/examples/msg/app-bittorrent/bittorrent.c +++ b/examples/msg/app-bittorrent/bittorrent.c @@ -29,10 +29,9 @@ int main(int argc, char *argv[]) xbt_dynar_t 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); + RngStream stream = RngStream_CreateStream(descr); + MSG_host_set_data(host, stream); } MSG_function_register("tracker", tracker); @@ -43,8 +42,9 @@ int main(int argc, char *argv[]) MSG_main(); xbt_dynar_foreach(host_list, i, host) { - RngStream stream = (RngStream) MSG_host_get_property_value(host, "stream"); + RngStream stream = (RngStream)MSG_host_get_data(host); RngStream_DeleteStream(&stream); + MSG_host_set_data(host, NULL); } xbt_dynar_free(&host_list); diff --git a/examples/msg/app-bittorrent/peer.c b/examples/msg/app-bittorrent/peer.c index 5acba5dd24..e27520e4a9 100644 --- a/examples/msg/app-bittorrent/peer.c +++ b/examples/msg/app-bittorrent/peer.c @@ -227,7 +227,7 @@ void peer_init(peer_t peer, int id, int seed) peer->current_pieces = xbt_dynar_new(sizeof(int), NULL); - peer->stream = (RngStream)MSG_host_get_property_value(MSG_host_self(), "stream"); + peer->stream = (RngStream)MSG_host_get_data(MSG_host_self()); peer->comm_received = NULL; peer->round = 0; diff --git a/examples/msg/app-bittorrent/tracker.c b/examples/msg/app-bittorrent/tracker.c index 55b329a6dd..c6e92552d1 100644 --- a/examples/msg/app-bittorrent/tracker.c +++ b/examples/msg/app-bittorrent/tracker.c @@ -20,7 +20,7 @@ int tracker(int argc, char *argv[]) { int i; - RngStream stream = (RngStream) MSG_host_get_property_value(MSG_host_self(), "stream"); + RngStream stream = (RngStream)MSG_host_get_data(MSG_host_self()); //Checking arguments xbt_assert(argc == 2, "Wrong number of arguments for the tracker."); //Retrieving end time diff --git a/examples/msg/dht-chord/dht-chord.c b/examples/msg/dht-chord/dht-chord.c index 57ae2ff013..f4264e40ae 100644 --- a/examples/msg/dht-chord/dht-chord.c +++ b/examples/msg/dht-chord/dht-chord.c @@ -43,7 +43,7 @@ static void chord_initialize(void) 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_host_set_data(host, stream); } } @@ -52,8 +52,9 @@ static void chord_exit(void) msg_host_t host; unsigned i; xbt_dynar_foreach(host_list, i, host) { - RngStream stream = (RngStream)MSG_host_get_property_value(host, "stream"); + RngStream stream = (RngStream)MSG_host_get_data(host); RngStream_DeleteStream(&stream); + MSG_host_set_data(host, NULL); } xbt_dynar_free(&host_list); @@ -712,7 +713,7 @@ static int node(int argc, char *argv[]) // initialize my node s_node_t node = {0}; node.id = xbt_str_parse_int(argv[1],"Invalid ID: %s"); - node.stream = (RngStream)MSG_host_get_property_value(MSG_host_self(), "stream"); + node.stream = (RngStream)MSG_host_get_data(MSG_host_self()); get_mailbox(node.id, node.mailbox); node.next_finger_to_fix = 0; node.fingers = xbt_new0(s_finger_t, nb_bits); -- 2.20.1