aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-16 16:03:20 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-16 16:03:20 +0000
commit16a6919a9f98ee9fa1fee9dd262906c321004a19 (patch)
treee09d4fe5191dc329b3e1b667f2914f8313bcba59 /src/testing
parent4d7904c62bb867c44e90b8e9f7cdbb4b283abc44 (diff)
downloadgnunet-16a6919a9f98ee9fa1fee9dd262906c321004a19.tar.gz
gnunet-16a6919a9f98ee9fa1fee9dd262906c321004a19.zip
even nicer indentation, thanks to LRN's indent patch
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing_reconnect.c3
-rw-r--r--src/testing/testing.c63
-rw-r--r--src/testing/testing_group.c218
-rw-r--r--src/testing/testing_peergroup.c28
4 files changed, 150 insertions, 162 deletions
diff --git a/src/testing/test_testing_reconnect.c b/src/testing/test_testing_reconnect.c
index 480bafdc6..69b871303 100644
--- a/src/testing/test_testing_reconnect.c
+++ b/src/testing/test_testing_reconnect.c
@@ -54,7 +54,8 @@ static int phase;
54 * Run the next phase of starting daemons, connecting them and 54 * Run the next phase of starting daemons, connecting them and
55 * stopping them again. 55 * stopping them again.
56 */ 56 */
57static void run_phase (); 57static void
58run_phase ();
58 59
59static void 60static void
60end2_cb (void *cls, const char *emsg) 61end2_cb (void *cls, const char *emsg)
diff --git a/src/testing/testing.c b/src/testing/testing.c
index c107ec593..3a712f071 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -164,8 +164,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
164#endif 164#endif
165} 165}
166 166
167static void start_fsm (void *cls, 167static void
168 const struct GNUNET_SCHEDULER_TaskContext *tc); 168start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
169 169
170#if WAIT_FOR_HELLO 170#if WAIT_FOR_HELLO
171/** 171/**
@@ -195,10 +195,9 @@ testing_init (void *cls, struct GNUNET_CORE_Handle *server,
195 d->server = NULL; 195 d->server = NULL;
196 if (GNUNET_YES == d->dead) 196 if (GNUNET_YES == d->dead)
197 GNUNET_TESTING_daemon_stop (d, 197 GNUNET_TESTING_daemon_stop (d,
198 GNUNET_TIME_absolute_get_remaining (d-> 198 GNUNET_TIME_absolute_get_remaining
199 max_timeout), 199 (d->max_timeout), d->dead_cb, d->dead_cb_cls,
200 d->dead_cb, d->dead_cb_cls, GNUNET_YES, 200 GNUNET_YES, GNUNET_NO);
201 GNUNET_NO);
202 else if (NULL != d->cb) 201 else if (NULL != d->cb)
203 d->cb (d->cb_cls, NULL, d->cfg, d, 202 d->cb (d->cb_cls, NULL, d->cfg, d,
204 _("Failed to connect to core service\n")); 203 _("Failed to connect to core service\n"));
@@ -233,10 +232,9 @@ testing_init (void *cls, struct GNUNET_CORE_Handle *server,
233 { 232 {
234 if (GNUNET_YES == d->dead) 233 if (GNUNET_YES == d->dead)
235 GNUNET_TESTING_daemon_stop (d, 234 GNUNET_TESTING_daemon_stop (d,
236 GNUNET_TIME_absolute_get_remaining (d-> 235 GNUNET_TIME_absolute_get_remaining
237 max_timeout), 236 (d->max_timeout), d->dead_cb, d->dead_cb_cls,
238 d->dead_cb, d->dead_cb_cls, GNUNET_YES, 237 GNUNET_YES, GNUNET_NO);
239 GNUNET_NO);
240 else if (NULL != d->cb) 238 else if (NULL != d->cb)
241 d->cb (d->cb_cls, &d->id, d->cfg, d, 239 d->cb (d->cb_cls, &d->id, d->cfg, d,
242 _("Failed to connect to transport service!\n")); 240 _("Failed to connect to transport service!\n"));
@@ -349,8 +347,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
349 if (NULL != cb) 347 if (NULL != cb)
350 cb (d->cb_cls, NULL, d->cfg, d, 348 cb (d->cb_cls, NULL, d->cfg, d,
351 (NULL == 349 (NULL ==
352 d-> 350 d->hostname) ?
353 hostname) ?
354 _("Failed to create pipe for `gnunet-peerinfo' process.\n") : 351 _("Failed to create pipe for `gnunet-peerinfo' process.\n") :
355 _("Failed to create pipe for `ssh' process.\n")); 352 _("Failed to create pipe for `ssh' process.\n"));
356 return; 353 return;
@@ -415,9 +412,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
415 if (NULL != cb) 412 if (NULL != cb)
416 cb (d->cb_cls, NULL, d->cfg, d, 413 cb (d->cb_cls, NULL, d->cfg, d,
417 (NULL == 414 (NULL ==
418 d-> 415 d->hostname) ? _("Failed to start `gnunet-peerinfo' process.\n")
419 hostname) ? _("Failed to start `gnunet-peerinfo' process.\n") : 416 : _("Failed to start `ssh' process.\n"));
420 _("Failed to start `ssh' process.\n"));
421 GNUNET_DISK_pipe_close (d->pipe_stdout); 417 GNUNET_DISK_pipe_close (d->pipe_stdout);
422 return; 418 return;
423 } 419 }
@@ -429,9 +425,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
429 d->task = 425 d->task =
430 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 426 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
431 (d->max_timeout), 427 (d->max_timeout),
432 GNUNET_DISK_pipe_handle (d-> 428 GNUNET_DISK_pipe_handle
433 pipe_stdout, 429 (d->pipe_stdout,
434 GNUNET_DISK_PIPE_END_READ), 430 GNUNET_DISK_PIPE_END_READ),
435 &start_fsm, d); 431 &start_fsm, d);
436 } 432 }
437 else /* Already have a hostkey! */ 433 else /* Already have a hostkey! */
@@ -464,9 +460,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
464 d->task = 460 d->task =
465 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 461 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
466 (d->max_timeout), 462 (d->max_timeout),
467 GNUNET_DISK_pipe_handle (d-> 463 GNUNET_DISK_pipe_handle
468 pipe_stdout, 464 (d->pipe_stdout,
469 GNUNET_DISK_PIPE_END_READ), 465 GNUNET_DISK_PIPE_END_READ),
470 &start_fsm, d); 466 &start_fsm, d);
471 return; 467 return;
472 } 468 }
@@ -614,8 +610,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
614 if (NULL != cb) 610 if (NULL != cb)
615 cb (d->cb_cls, NULL, d->cfg, d, 611 cb (d->cb_cls, NULL, d->cfg, d,
616 (NULL == 612 (NULL ==
617 d-> 613 d->hostname) ? _("Failed to start `gnunet-arm' process.\n") :
618 hostname) ? _("Failed to start `gnunet-arm' process.\n") :
619 _("Failed to start `ssh' process.\n")); 614 _("Failed to start `ssh' process.\n"));
620 return; 615 return;
621 } 616 }
@@ -639,8 +634,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
639 if (NULL != cb) 634 if (NULL != cb)
640 cb (d->cb_cls, NULL, d->cfg, d, 635 cb (d->cb_cls, NULL, d->cfg, d,
641 (NULL == 636 (NULL ==
642 d-> 637 d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
643 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
644 _("`ssh' does not seem to terminate.\n")); 638 _("`ssh' does not seem to terminate.\n"));
645 GNUNET_CONFIGURATION_destroy (d->cfg); 639 GNUNET_CONFIGURATION_destroy (d->cfg);
646 GNUNET_free (d->cfgfile); 640 GNUNET_free (d->cfgfile);
@@ -698,10 +692,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
698 { 692 {
699 if (GNUNET_YES == d->dead) 693 if (GNUNET_YES == d->dead)
700 GNUNET_TESTING_daemon_stop (d, 694 GNUNET_TESTING_daemon_stop (d,
701 GNUNET_TIME_absolute_get_remaining (d-> 695 GNUNET_TIME_absolute_get_remaining
702 max_timeout), 696 (d->max_timeout), d->dead_cb,
703 d->dead_cb, d->dead_cb_cls, GNUNET_YES, 697 d->dead_cb_cls, GNUNET_YES, GNUNET_NO);
704 GNUNET_NO);
705 else if (NULL != d->cb) 698 else if (NULL != d->cb)
706 d->cb (d->cb_cls, &d->id, d->cfg, d, 699 d->cb (d->cb_cls, &d->id, d->cfg, d,
707 _("Failed to connect to transport service!\n")); 700 _("Failed to connect to transport service!\n"));
@@ -763,8 +756,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
763 if (NULL != cb) 756 if (NULL != cb)
764 cb (d->cb_cls, NULL, d->cfg, d, 757 cb (d->cb_cls, NULL, d->cfg, d,
765 (NULL == 758 (NULL ==
766 d-> 759 d->hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
767 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
768 _("`ssh' does not seem to terminate.\n")); 760 _("`ssh' does not seem to terminate.\n"));
769 return; 761 return;
770 } 762 }
@@ -782,8 +774,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
782 if (NULL != cb) 774 if (NULL != cb)
783 cb (d->cb_cls, NULL, d->cfg, d, 775 cb (d->cb_cls, NULL, d->cfg, d,
784 (NULL == 776 (NULL ==
785 d-> 777 d->hostname) ?
786 hostname) ?
787 _ 778 _
788 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n") 779 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n")
789 : _("`ssh' does not seem to terminate.\n")); 780 : _("`ssh' does not seem to terminate.\n"));
@@ -1946,9 +1937,9 @@ struct ConnectContext
1946 1937
1947 1938
1948/** Forward declaration **/ 1939/** Forward declaration **/
1949static void reattempt_daemons_connect (void *cls, 1940static void
1950 const struct GNUNET_SCHEDULER_TaskContext 1941reattempt_daemons_connect (void *cls,
1951 *tc); 1942 const struct GNUNET_SCHEDULER_TaskContext *tc);
1952 1943
1953 1944
1954/** 1945/**
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index d03cb307b..88c51abe0 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -1630,19 +1630,23 @@ remove_connections (struct GNUNET_TESTING_PeerGroup *pg, unsigned int first,
1630 } 1630 }
1631#else 1631#else
1632 if (GNUNET_YES == 1632 if (GNUNET_YES ==
1633 GNUNET_CONTAINER_multihashmap_contains (pg->peers[first]. 1633 GNUNET_CONTAINER_multihashmap_contains (pg->
1634 blacklisted_peers, &hash_second)) 1634 peers[first].blacklisted_peers,
1635 &hash_second))
1635 { 1636 {
1636 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[first]. 1637 GNUNET_CONTAINER_multihashmap_remove_all (pg->
1637 blacklisted_peers, &hash_second); 1638 peers[first].blacklisted_peers,
1639 &hash_second);
1638 } 1640 }
1639 1641
1640 if (GNUNET_YES == 1642 if (GNUNET_YES ==
1641 GNUNET_CONTAINER_multihashmap_contains (pg->peers[second]. 1643 GNUNET_CONTAINER_multihashmap_contains (pg->
1642 blacklisted_peers, &hash_first)) 1644 peers[second].blacklisted_peers,
1645 &hash_first))
1643 { 1646 {
1644 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[second]. 1647 GNUNET_CONTAINER_multihashmap_remove_all (pg->
1645 blacklisted_peers, &hash_first); 1648 peers[second].blacklisted_peers,
1649 &hash_first);
1646 } 1650 }
1647#endif 1651#endif
1648 1652
@@ -2864,8 +2868,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2864 conn_iter = pg->peers[pg_iter].allowed_peers_head; 2868 conn_iter = pg->peers[pg_iter].allowed_peers_head;
2865 while (conn_iter != NULL) 2869 while (conn_iter != NULL)
2866 { 2870 {
2867 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id. 2871 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->
2868 hashPubKey, &peer_enc); 2872 id.hashPubKey, &peer_enc);
2869 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc); 2873 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc);
2870 conn_iter = conn_iter->next; 2874 conn_iter = conn_iter->next;
2871 } 2875 }
@@ -3051,15 +3055,16 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3051 conn_iter = pg->peers[pg_iter].blacklisted_peers_head; 3055 conn_iter = pg->peers[pg_iter].blacklisted_peers_head;
3052 while (conn_iter != NULL) 3056 while (conn_iter != NULL)
3053 { 3057 {
3054 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id. 3058 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->
3055 hashPubKey, &peer_enc); 3059 id.hashPubKey, &peer_enc);
3056 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc); 3060 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc);
3057 conn_iter = conn_iter->next; 3061 conn_iter = conn_iter->next;
3058 } 3062 }
3059#else 3063#else
3060 blacklist_ctx.transport = pos; 3064 blacklist_ctx.transport = pos;
3061 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter]. 3065 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->
3062 blacklisted_peers, 3066 peers
3067 [pg_iter].blacklisted_peers,
3063 &blacklist_file_iterator, 3068 &blacklist_file_iterator,
3064 &blacklist_ctx); 3069 &blacklist_ctx);
3065#endif 3070#endif
@@ -3176,8 +3181,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3176} 3181}
3177 3182
3178/* Forward Declaration */ 3183/* Forward Declaration */
3179static void schedule_connect (void *cls, 3184static void
3180 const struct GNUNET_SCHEDULER_TaskContext *tc); 3185schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
3181 3186
3182/** 3187/**
3183 * Choose a random peer's next connection to create, and 3188 * Choose a random peer's next connection to create, and
@@ -3216,9 +3221,8 @@ preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg)
3216 3221
3217#if USE_SEND_HELLOS 3222#if USE_SEND_HELLOS
3218/* Forward declaration */ 3223/* Forward declaration */
3219static void schedule_send_hellos (void *cls, 3224static void
3220 const struct GNUNET_SCHEDULER_TaskContext 3225schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
3221 *tc);
3222 3226
3223/** 3227/**
3224 * Close connections and free the hello context. 3228 * Close connections and free the hello context.
@@ -3319,19 +3323,19 @@ send_core_connect_requests (void *cls,
3319 conn = send_hello_context->peer->connect_peers_head; 3323 conn = send_hello_context->peer->connect_peers_head;
3320 while (conn != NULL) 3324 while (conn != NULL)
3321 { 3325 {
3322 GNUNET_CORE_peer_request_connect (send_hello_context->peer->daemon-> 3326 GNUNET_CORE_peer_request_connect (send_hello_context->peer->
3323 server, 3327 daemon->server,
3324 &send_hello_context->pg->peers[conn-> 3328 &send_hello_context->pg->
3325 index]. 3329 peers[conn->index].daemon->id, NULL,
3326 daemon->id, NULL, NULL); 3330 NULL);
3327 conn = conn->next; 3331 conn = conn->next;
3328 } 3332 }
3329 send_hello_context->core_connect_task = 3333 send_hello_context->core_connect_task =
3330 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3334 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3331 (send_hello_context->pg->ct_ctx. 3335 (send_hello_context->pg->
3332 connect_timeout, 3336 ct_ctx.connect_timeout,
3333 send_hello_context->pg->ct_ctx. 3337 send_hello_context->pg->
3334 connect_attempts), 3338 ct_ctx.connect_attempts),
3335 &send_core_connect_requests, 3339 &send_core_connect_requests,
3336 send_hello_context); 3340 send_hello_context);
3337 } 3341 }
@@ -3522,10 +3526,10 @@ hello_sent_callback (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3522 3526
3523 send_hello_context->core_connect_task = 3527 send_hello_context->core_connect_task =
3524 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3528 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3525 (send_hello_context->pg->ct_ctx. 3529 (send_hello_context->pg->
3526 connect_timeout, 3530 ct_ctx.connect_timeout,
3527 send_hello_context->pg->ct_ctx. 3531 send_hello_context->pg->
3528 connect_attempts), 3532 ct_ctx.connect_attempts),
3529 &send_core_connect_requests, 3533 &send_core_connect_requests,
3530 send_hello_context); 3534 send_hello_context);
3531 } 3535 }
@@ -3584,14 +3588,14 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3584 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3588 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3585 _("Offering Hello of peer %s to peer %s\n"), 3589 _("Offering Hello of peer %s to peer %s\n"),
3586 send_hello_context->peer->daemon->shortname, 3590 send_hello_context->peer->daemon->shortname,
3587 pg->peers[send_hello_context->peer_pos->index].daemon-> 3591 pg->peers[send_hello_context->peer_pos->index].
3588 shortname); 3592 daemon->shortname);
3589#endif 3593#endif
3590 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, 3594 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th,
3591 (const struct GNUNET_MessageHeader *) pg-> 3595 (const struct GNUNET_MessageHeader *)
3592 peers[send_hello_context->peer_pos->index]. 3596 pg->peers[send_hello_context->peer_pos->
3593 daemon->hello, &hello_sent_callback, 3597 index].daemon->hello,
3594 send_hello_context); 3598 &hello_sent_callback, send_hello_context);
3595 send_hello_context->peer_pos = send_hello_context->peer_pos->next; 3599 send_hello_context->peer_pos = send_hello_context->peer_pos->next;
3596 GNUNET_assert (send_hello_context->peer->daemon->th != NULL); 3600 GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
3597 } 3601 }
@@ -3647,10 +3651,12 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first,
3647 second_cfg, first_cfg, second_daemon, first_daemon, 3651 second_cfg, first_cfg, second_daemon, first_daemon,
3648 emsg); 3652 emsg);
3649 3653
3650 GNUNET_CONTAINER_DLL_remove (pg->peers[connect_ctx->second_index]. 3654 GNUNET_CONTAINER_DLL_remove (pg->
3651 connect_peers_head, 3655 peers[connect_ctx->
3652 pg->peers[connect_ctx->second_index]. 3656 second_index].connect_peers_head,
3653 connect_peers_tail, connection); 3657 pg->peers[connect_ctx->
3658 second_index].connect_peers_tail,
3659 connection);
3654 GNUNET_free (connection); 3660 GNUNET_free (connection);
3655 } 3661 }
3656 3662
@@ -3711,10 +3717,10 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3711#endif 3717#endif
3712 pg->outstanding_connects++; 3718 pg->outstanding_connects++;
3713 pg->total_connects_scheduled++; 3719 pg->total_connects_scheduled++;
3714 GNUNET_TESTING_daemons_connect (pg->peers[connect_context->first_index]. 3720 GNUNET_TESTING_daemons_connect (pg->
3715 daemon, 3721 peers[connect_context->first_index].daemon,
3716 pg->peers[connect_context->second_index]. 3722 pg->peers[connect_context->
3717 daemon, 3723 second_index].daemon,
3718 connect_context->ct_ctx->connect_timeout, 3724 connect_context->ct_ctx->connect_timeout,
3719 connect_context->ct_ctx->connect_attempts, 3725 connect_context->ct_ctx->connect_attempts,
3720#if USE_SEND_HELLOS 3726#if USE_SEND_HELLOS
@@ -4224,8 +4230,8 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4224 if (random_number < random_ctx->percentage) 4230 if (random_number < random_ctx->percentage)
4225 { 4231 {
4226 GNUNET_assert (GNUNET_OK == 4232 GNUNET_assert (GNUNET_OK ==
4227 GNUNET_CONTAINER_multihashmap_put (random_ctx->first-> 4233 GNUNET_CONTAINER_multihashmap_put (random_ctx->
4228 connect_peers_working_set, 4234 first->connect_peers_working_set,
4229 key, value, 4235 key, value,
4230 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4236 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4231 } 4237 }
@@ -4235,12 +4241,12 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4235 hash_from_uid (random_ctx->first_uid, &first_hash); 4241 hash_from_uid (random_ctx->first_uid, &first_hash);
4236 GNUNET_assert (random_ctx->pg->total > second_pos); 4242 GNUNET_assert (random_ctx->pg->total > second_pos);
4237 GNUNET_assert (GNUNET_YES == 4243 GNUNET_assert (GNUNET_YES ==
4238 GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg-> 4244 GNUNET_CONTAINER_multihashmap_remove (random_ctx->
4239 peers[second_pos]. 4245 pg->peers
4240 connect_peers, 4246 [second_pos].connect_peers,
4241 &first_hash, 4247 &first_hash,
4242 random_ctx->first-> 4248 random_ctx->
4243 daemon)); 4249 first->daemon));
4244 4250
4245 return GNUNET_YES; 4251 return GNUNET_YES;
4246} 4252}
@@ -4270,29 +4276,29 @@ minimum_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4270 if (min_ctx->pg_array[i] == min_ctx->current) 4276 if (min_ctx->pg_array[i] == min_ctx->current)
4271 { 4277 {
4272 GNUNET_assert (GNUNET_OK == 4278 GNUNET_assert (GNUNET_OK ==
4273 GNUNET_CONTAINER_multihashmap_put (min_ctx->first-> 4279 GNUNET_CONTAINER_multihashmap_put (min_ctx->
4274 connect_peers_working_set, 4280 first->connect_peers_working_set,
4275 key, value, 4281 key, value,
4276 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4282 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4277 uid_from_hash (key, &second_pos); 4283 uid_from_hash (key, &second_pos);
4278 hash_from_uid (min_ctx->first_uid, &first_hash); 4284 hash_from_uid (min_ctx->first_uid, &first_hash);
4279 GNUNET_assert (min_ctx->pg->total > second_pos); 4285 GNUNET_assert (min_ctx->pg->total > second_pos);
4280 GNUNET_assert (GNUNET_OK == 4286 GNUNET_assert (GNUNET_OK ==
4281 GNUNET_CONTAINER_multihashmap_put (min_ctx->pg-> 4287 GNUNET_CONTAINER_multihashmap_put (min_ctx->
4282 peers[second_pos]. 4288 pg->peers
4283 connect_peers_working_set, 4289 [second_pos].connect_peers_working_set,
4284 &first_hash, 4290 &first_hash,
4285 min_ctx-> 4291 min_ctx->first->
4286 first->daemon, 4292 daemon,
4287 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4293 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4288 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */ 4294 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */
4289 GNUNET_assert (GNUNET_YES == 4295 GNUNET_assert (GNUNET_YES ==
4290 GNUNET_CONTAINER_multihashmap_remove (min_ctx->pg-> 4296 GNUNET_CONTAINER_multihashmap_remove (min_ctx->
4291 peers[second_pos]. 4297 pg->peers
4292 connect_peers, 4298 [second_pos].connect_peers,
4293 &first_hash, 4299 &first_hash,
4294 min_ctx->first-> 4300 min_ctx->
4295 daemon)); 4301 first->daemon));
4296 } 4302 }
4297 } 4303 }
4298 min_ctx->current++; 4304 min_ctx->current++;
@@ -4321,28 +4327,26 @@ dfs_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4321 if (dfs_ctx->current == dfs_ctx->chosen) 4327 if (dfs_ctx->current == dfs_ctx->chosen)
4322 { 4328 {
4323 GNUNET_assert (GNUNET_OK == 4329 GNUNET_assert (GNUNET_OK ==
4324 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->first-> 4330 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->
4325 connect_peers_working_set, 4331 first->connect_peers_working_set,
4326 key, value, 4332 key, value,
4327 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4333 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4328 uid_from_hash (key, &dfs_ctx->second_uid); 4334 uid_from_hash (key, &dfs_ctx->second_uid);
4329 hash_from_uid (dfs_ctx->first_uid, &first_hash); 4335 hash_from_uid (dfs_ctx->first_uid, &first_hash);
4330 GNUNET_assert (GNUNET_OK == 4336 GNUNET_assert (GNUNET_OK ==
4331 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg-> 4337 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->
4332 peers 4338 pg->peers[dfs_ctx->
4333 [dfs_ctx->second_uid]. 4339 second_uid].connect_peers_working_set,
4334 connect_peers_working_set,
4335 &first_hash, 4340 &first_hash,
4336 dfs_ctx->first->daemon, 4341 dfs_ctx->first->daemon,
4337 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4342 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4338 GNUNET_assert (GNUNET_YES == 4343 GNUNET_assert (GNUNET_YES ==
4339 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx->pg-> 4344 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx->
4340 peers[dfs_ctx-> 4345 pg->peers
4341 second_uid]. 4346 [dfs_ctx->second_uid].connect_peers,
4342 connect_peers,
4343 &first_hash, 4347 &first_hash,
4344 dfs_ctx->first-> 4348 dfs_ctx->
4345 daemon)); 4349 first->daemon));
4346 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */ 4350 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */
4347 return GNUNET_NO; /* We have found our peer, don't iterate more */ 4351 return GNUNET_NO; /* We have found our peer, don't iterate more */
4348 } 4352 }
@@ -4469,8 +4473,9 @@ count_workingset_connections (struct GNUNET_TESTING_PeerGroup *pg)
4469 } 4473 }
4470#else 4474#else
4471 count += 4475 count +=
4472 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter]. 4476 GNUNET_CONTAINER_multihashmap_size (pg->
4473 connect_peers_working_set); 4477 peers
4478 [pg_iter].connect_peers_working_set);
4474#endif 4479#endif
4475 } 4480 }
4476 4481
@@ -4561,10 +4566,8 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4561 minimum_ctx.first_uid = pg_iter; 4566 minimum_ctx.first_uid = pg_iter;
4562 minimum_ctx.pg_array = 4567 minimum_ctx.pg_array =
4563 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 4568 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
4564 GNUNET_CONTAINER_multihashmap_size (pg-> 4569 GNUNET_CONTAINER_multihashmap_size
4565 peers 4570 (pg->peers[pg_iter].connect_peers));
4566 [pg_iter].
4567 connect_peers));
4568 minimum_ctx.first = &pg->peers[pg_iter]; 4571 minimum_ctx.first = &pg->peers[pg_iter];
4569 minimum_ctx.pg = pg; 4572 minimum_ctx.pg = pg;
4570 minimum_ctx.num_to_add = num; 4573 minimum_ctx.num_to_add = num;
@@ -4654,13 +4657,13 @@ find_closest_peers (void *cls, const GNUNET_HashCode * key, void *value)
4654 &closest_ctx->curr_peer->daemon->id.hashPubKey) > 4657 &closest_ctx->curr_peer->daemon->id.hashPubKey) >
4655 closest_ctx->closest_dist)) && 4658 closest_ctx->closest_dist)) &&
4656 (GNUNET_YES != 4659 (GNUNET_YES !=
4657 GNUNET_CONTAINER_multihashmap_contains (closest_ctx->curr_peer-> 4660 GNUNET_CONTAINER_multihashmap_contains (closest_ctx->
4658 connect_peers, key))) 4661 curr_peer->connect_peers, key)))
4659 { 4662 {
4660 closest_ctx->closest_dist = 4663 closest_ctx->closest_dist =
4661 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey, 4664 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey,
4662 &closest_ctx->curr_peer->daemon->id. 4665 &closest_ctx->curr_peer->daemon->
4663 hashPubKey); 4666 id.hashPubKey);
4664 closest_ctx->closest = daemon; 4667 closest_ctx->closest = daemon;
4665 uid_from_hash (key, &closest_ctx->closest_num); 4668 uid_from_hash (key, &closest_ctx->closest_num);
4666 } 4669 }
@@ -4747,8 +4750,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4747 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 4750 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
4748 { 4751 {
4749 temp_count = 4752 temp_count =
4750 count_connections (pg->peers[pg_iter]. 4753 count_connections (pg->
4751 connect_peers_working_set_head); 4754 peers[pg_iter].connect_peers_working_set_head);
4752 if (temp_count < least_connections) 4755 if (temp_count < least_connections)
4753 { 4756 {
4754 starting_peer = pg_iter; 4757 starting_peer = pg_iter;
@@ -4802,8 +4805,9 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4802 { 4805 {
4803 starting_peer = pg_iter; 4806 starting_peer = pg_iter;
4804 least_connections = 4807 least_connections =
4805 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter]. 4808 GNUNET_CONTAINER_multihashmap_size (pg->
4806 connect_peers_working_set); 4809 peers
4810 [pg_iter].connect_peers_working_set);
4807 } 4811 }
4808 } 4812 }
4809 } 4813 }
@@ -4817,28 +4821,25 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4817 /* Choose a random peer from the chosen peers set of connections to add */ 4821 /* Choose a random peer from the chosen peers set of connections to add */
4818 dfs_ctx.chosen = 4822 dfs_ctx.chosen =
4819 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4823 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
4820 GNUNET_CONTAINER_multihashmap_size (pg-> 4824 GNUNET_CONTAINER_multihashmap_size (pg->peers
4821 peers 4825 [starting_peer].connect_peers));
4822 [starting_peer].
4823 connect_peers));
4824 dfs_ctx.first_uid = starting_peer; 4826 dfs_ctx.first_uid = starting_peer;
4825 dfs_ctx.first = &pg->peers[starting_peer]; 4827 dfs_ctx.first = &pg->peers[starting_peer];
4826 dfs_ctx.pg = pg; 4828 dfs_ctx.pg = pg;
4827 dfs_ctx.current = 0; 4829 dfs_ctx.current = 0;
4828 4830
4829 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[starting_peer]. 4831 GNUNET_CONTAINER_multihashmap_iterate (pg->
4830 connect_peers, &dfs_connect_iterator, 4832 peers[starting_peer].connect_peers,
4831 &dfs_ctx); 4833 &dfs_connect_iterator, &dfs_ctx);
4832 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */ 4834 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */
4833 hash_from_uid (dfs_ctx.second_uid, &second_hash); 4835 hash_from_uid (dfs_ctx.second_uid, &second_hash);
4834 GNUNET_assert (GNUNET_YES == 4836 GNUNET_assert (GNUNET_YES ==
4835 GNUNET_CONTAINER_multihashmap_remove (pg-> 4837 GNUNET_CONTAINER_multihashmap_remove (pg->peers
4836 peers[starting_peer]. 4838 [starting_peer].connect_peers,
4837 connect_peers,
4838 &second_hash, 4839 &second_hash,
4839 pg->peers[dfs_ctx. 4840 pg->
4840 second_uid]. 4841 peers
4841 daemon)); 4842 [dfs_ctx.second_uid].daemon));
4842 starting_peer = dfs_ctx.second_uid; 4843 starting_peer = dfs_ctx.second_uid;
4843 } 4844 }
4844 4845
@@ -5620,8 +5621,8 @@ schedule_churn_restart (void *cls,
5620 { 5621 {
5621 if (startup_ctx->churn_ctx->service != NULL) 5622 if (startup_ctx->churn_ctx->service != NULL)
5622 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon, 5623 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon,
5623 startup_ctx->churn_ctx-> 5624 startup_ctx->
5624 service, 5625 churn_ctx->service,
5625 startup_ctx->timeout, 5626 startup_ctx->timeout,
5626 &churn_start_callback, 5627 &churn_start_callback,
5627 startup_ctx); 5628 startup_ctx);
@@ -5880,9 +5881,8 @@ call_hostkey_callbacks (void *cls,
5880 for (i = 0; i < pg->total; i++) 5881 for (i = 0; i < pg->total; i++)
5881 { 5882 {
5882 if (pg->peers[i].internal_context.hostkey_callback != NULL) 5883 if (pg->peers[i].internal_context.hostkey_callback != NULL)
5883 pg->peers[i].internal_context.hostkey_callback (pg-> 5884 pg->peers[i].internal_context.hostkey_callback (pg->peers[i].
5884 peers[i].internal_context. 5885 internal_context.hostkey_cls,
5885 hostkey_cls,
5886 &pg->peers[i].daemon->id, 5886 &pg->peers[i].daemon->id,
5887 pg->peers[i].daemon, 5887 pg->peers[i].daemon,
5888 NULL); 5888 NULL);
diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c
index a76c7cc26..ba25a62bd 100644
--- a/src/testing/testing_peergroup.c
+++ b/src/testing/testing_peergroup.c
@@ -346,12 +346,12 @@ internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
346 /* Get duration in seconds */ 346 /* Get duration in seconds */
347 duration = 347 duration =
348 GNUNET_TIME_absolute_get_difference (connect_last_time, 348 GNUNET_TIME_absolute_get_difference (connect_last_time,
349 GNUNET_TIME_absolute_get ()). 349 GNUNET_TIME_absolute_get
350 rel_value / 1000; 350 ()).rel_value / 1000;
351 total_duration = 351 total_duration =
352 GNUNET_TIME_absolute_get_difference (connect_start_time, 352 GNUNET_TIME_absolute_get_difference (connect_start_time,
353 GNUNET_TIME_absolute_get ()). 353 GNUNET_TIME_absolute_get
354 rel_value / 1000; 354 ()).rel_value / 1000;
355 355
356 failed_conns_per_sec_recent = (double) new_failed_connections / duration; 356 failed_conns_per_sec_recent = (double) new_failed_connections / duration;
357 failed_conns_per_sec_total = (double) failed_connections / total_duration; 357 failed_conns_per_sec_total = (double) failed_connections / total_duration;
@@ -422,8 +422,8 @@ internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first,
422#if TIMING 422#if TIMING
423 total_duration = 423 total_duration =
424 GNUNET_TIME_absolute_get_difference (connect_start_time, 424 GNUNET_TIME_absolute_get_difference (connect_start_time,
425 GNUNET_TIME_absolute_get ()). 425 GNUNET_TIME_absolute_get
426 rel_value / 1000; 426 ()).rel_value / 1000;
427 failed_conns_per_sec_total = (double) failed_connections / total_duration; 427 failed_conns_per_sec_total = (double) failed_connections / total_duration;
428 conns_per_sec_total = (double) total_connections / total_duration; 428 conns_per_sec_total = (double) total_connections / total_duration;
429 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 429 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -493,10 +493,8 @@ internal_peers_started_callback (void *cls,
493 pg_start_ctx->expected_connections = 493 pg_start_ctx->expected_connections =
494 GNUNET_TESTING_connect_topology (pg_start_ctx->pg, 494 GNUNET_TESTING_connect_topology (pg_start_ctx->pg,
495 pg_start_ctx->connect_topology, 495 pg_start_ctx->connect_topology,
496 pg_start_ctx-> 496 pg_start_ctx->connect_topology_option,
497 connect_topology_option, 497 pg_start_ctx->connect_topology_option_modifier,
498 pg_start_ctx->
499 connect_topology_option_modifier,
500 DEFAULT_CONNECT_TIMEOUT, 498 DEFAULT_CONNECT_TIMEOUT,
501 pg_start_ctx->connect_attempts, NULL, 499 pg_start_ctx->connect_attempts, NULL,
502 NULL); 500 NULL);
@@ -736,8 +734,7 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
736 if (GNUNET_OK != 734 if (GNUNET_OK !=
737 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 735 GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
738 "max_outstanding_connections", 736 "max_outstanding_connections",
739 &pg_start_ctx-> 737 &pg_start_ctx->max_concurrent_connections))
740 max_concurrent_connections))
741 { 738 {
742 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", 739 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
743 "testing", "max_outstanding_connections"); 740 "testing", "max_outstanding_connections");
@@ -857,8 +854,8 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
857 "connect_topology_option", 854 "connect_topology_option",
858 &temp_str)) && 855 &temp_str)) &&
859 (GNUNET_NO == 856 (GNUNET_NO ==
860 GNUNET_TESTING_topology_option_get (&pg_start_ctx-> 857 GNUNET_TESTING_topology_option_get
861 connect_topology_option, temp_str))) 858 (&pg_start_ctx->connect_topology_option, temp_str)))
862 { 859 {
863 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 860 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
864 "Invalid connect topology option `%s' given for section %s option %s\n", 861 "Invalid connect topology option `%s' given for section %s option %s\n",
@@ -889,8 +886,7 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
889 if (GNUNET_YES != 886 if (GNUNET_YES !=
890 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 887 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
891 "blacklist_transports", 888 "blacklist_transports",
892 &pg_start_ctx-> 889 &pg_start_ctx->restrict_transports))
893 restrict_transports))
894 pg_start_ctx->restrict_transports = NULL; 890 pg_start_ctx->restrict_transports = NULL;
895 891
896 pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE; 892 pg_start_ctx->restrict_topology = GNUNET_TESTING_TOPOLOGY_NONE;