diff options
Diffstat (limited to 'src/messenger/testing_messenger_setup.c')
-rw-r--r-- | src/messenger/testing_messenger_setup.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/messenger/testing_messenger_setup.c b/src/messenger/testing_messenger_setup.c index 65cf12e73..dbab3e82d 100644 --- a/src/messenger/testing_messenger_setup.c +++ b/src/messenger/testing_messenger_setup.c | |||
@@ -53,7 +53,7 @@ struct test_peer { | |||
53 | struct GNUNET_MESSENGER_Handle *handle; | 53 | struct GNUNET_MESSENGER_Handle *handle; |
54 | struct GNUNET_MESSENGER_Room *room; | 54 | struct GNUNET_MESSENGER_Room *room; |
55 | 55 | ||
56 | unsigned int peer_messages; | 56 | struct GNUNET_CONTAINER_MultiPeerMap *map; |
57 | 57 | ||
58 | const char *message; | 58 | const char *message; |
59 | }; | 59 | }; |
@@ -79,7 +79,6 @@ shutdown_cb (void *cls) | |||
79 | { | 79 | { |
80 | struct test_properties *properties = cls; | 80 | struct test_properties *properties = cls; |
81 | 81 | ||
82 | |||
83 | for (unsigned int i = 0; i < properties->num_peer; i++) | 82 | for (unsigned int i = 0; i < properties->num_peer; i++) |
84 | { | 83 | { |
85 | struct test_peer *peer = &properties->peers[i]; | 84 | struct test_peer *peer = &properties->peers[i]; |
@@ -109,6 +108,9 @@ shutdown_cb (void *cls) | |||
109 | if (peer->handle) | 108 | if (peer->handle) |
110 | GNUNET_MESSENGER_disconnect (peer->handle); | 109 | GNUNET_MESSENGER_disconnect (peer->handle); |
111 | 110 | ||
111 | if (peer->map) | ||
112 | GNUNET_CONTAINER_multipeermap_destroy (peer->map); | ||
113 | |||
112 | peer->handle = NULL; | 114 | peer->handle = NULL; |
113 | } | 115 | } |
114 | 116 | ||
@@ -124,8 +126,6 @@ shutdown_cb (void *cls) | |||
124 | properties->barrier = NULL; | 126 | properties->barrier = NULL; |
125 | } | 127 | } |
126 | 128 | ||
127 | |||
128 | |||
129 | static void | 129 | static void |
130 | end_cb (void *cls) | 130 | end_cb (void *cls) |
131 | { | 131 | { |
@@ -281,11 +281,13 @@ on_message (void *cls, | |||
281 | GNUNET_h2s(hash)); | 281 | GNUNET_h2s(hash)); |
282 | 282 | ||
283 | if (GNUNET_MESSENGER_KIND_PEER == message->header.kind) | 283 | if (GNUNET_MESSENGER_KIND_PEER == message->header.kind) |
284 | peer->peer_messages++; | 284 | GNUNET_CONTAINER_multipeermap_put (peer->map, &(message->body.peer.peer), NULL, |
285 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
285 | 286 | ||
286 | if (peer->props->num_hosts == peer->peer_messages) | 287 | const uint32_t num_peers = GNUNET_CONTAINER_multipeermap_size (peer->map); |
288 | if (peer->props->num_hosts == num_peers) | ||
287 | peer->wait = GNUNET_wait_barrier (peer->props->barrier, &barrier2_wait_cb, peer); | 289 | peer->wait = GNUNET_wait_barrier (peer->props->barrier, &barrier2_wait_cb, peer); |
288 | else if (peer->props->num_hosts < peer->peer_messages) | 290 | else if (peer->props->num_hosts < num_peers) |
289 | { | 291 | { |
290 | if (peer->wait) | 292 | if (peer->wait) |
291 | GNUNET_cancel_wait_barrier(peer->wait); | 293 | GNUNET_cancel_wait_barrier(peer->wait); |
@@ -377,7 +379,7 @@ on_peer (void *cb_cls, | |||
377 | return; | 379 | return; |
378 | } | 380 | } |
379 | 381 | ||
380 | peer->handle = GNUNET_MESSENGER_connect (pinfo->result.cfg, TEST_NAME, NULL, NULL, &on_message, peer); | 382 | peer->handle = GNUNET_MESSENGER_connect (pinfo->result.cfg, TEST_NAME, NULL, &on_message, peer); |
381 | 383 | ||
382 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_get_peer_identity( | 384 | GNUNET_assert(GNUNET_OK == GNUNET_CRYPTO_get_peer_identity( |
383 | pinfo->result.cfg, &(peer->peer_id) | 385 | pinfo->result.cfg, &(peer->peer_id) |
@@ -427,6 +429,8 @@ run (void *cls, | |||
427 | 429 | ||
428 | peer->peer = event->details.peer_start.peer; | 430 | peer->peer = event->details.peer_start.peer; |
429 | peer->op = GNUNET_TESTBED_peer_get_information (peer->peer, GNUNET_TESTBED_PIT_CONFIGURATION, on_peer, peer); | 431 | peer->op = GNUNET_TESTBED_peer_get_information (peer->peer, GNUNET_TESTBED_PIT_CONFIGURATION, on_peer, peer); |
432 | |||
433 | peer->map = GNUNET_CONTAINER_multipeermap_create(peer->props->num_hosts, GNUNET_NO); | ||
430 | } | 434 | } |
431 | 435 | ||
432 | static void | 436 | static void |