diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-11-03 21:10:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-11-03 21:10:01 +0000 |
commit | 3f13ad89e3bfa3872fa09bc53e503ae61a2ebb88 (patch) | |
tree | f1c50fc22ea9dd2473f7ce19ec491aa3db75c8b0 /src/topology | |
parent | 658ddbb406b6db7e8b29646f5ba8510d7a029c15 (diff) | |
download | gnunet-3f13ad89e3bfa3872fa09bc53e503ae61a2ebb88.tar.gz gnunet-3f13ad89e3bfa3872fa09bc53e503ae61a2ebb88.zip |
adding some debug messages
Diffstat (limited to 'src/topology')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 178 | ||||
-rw-r--r-- | src/topology/test_gnunet_service_topology.c | 48 |
2 files changed, 210 insertions, 16 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 01c65679c..2f58ac126 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "gnunet_util_lib.h" | 33 | #include "gnunet_util_lib.h" |
34 | 34 | ||
35 | 35 | ||
36 | #define DEBUG_TOPOLOGY GNUNET_NO | 36 | #define DEBUG_TOPOLOGY GNUNET_YES |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * For how long do we blacklist a peer after a failed | 39 | * For how long do we blacklist a peer after a failed |
@@ -243,6 +243,12 @@ static size_t | |||
243 | ready_callback (void *cls, | 243 | ready_callback (void *cls, |
244 | size_t size, void *buf) | 244 | size_t size, void *buf) |
245 | { | 245 | { |
246 | #if DEBUG_TOPOLOGY | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
248 | (buf == NULL) | ||
249 | ? "Core told us that our attempt to connect failed.\n" | ||
250 | : "Core told us that our attempt to connect worked. Good!\n"); | ||
251 | #endif | ||
246 | return 0; | 252 | return 0; |
247 | } | 253 | } |
248 | 254 | ||
@@ -277,6 +283,11 @@ attempt_connect (const struct GNUNET_PeerIdentity *peer, | |||
277 | pos->blacklisted_until = GNUNET_TIME_relative_to_absolute (BLACKLIST_AFTER_ATTEMPT_FRIEND); | 283 | pos->blacklisted_until = GNUNET_TIME_relative_to_absolute (BLACKLIST_AFTER_ATTEMPT_FRIEND); |
278 | else | 284 | else |
279 | pos->blacklisted_until = GNUNET_TIME_relative_to_absolute (BLACKLIST_AFTER_ATTEMPT); | 285 | pos->blacklisted_until = GNUNET_TIME_relative_to_absolute (BLACKLIST_AFTER_ATTEMPT); |
286 | #if DEBUG_TOPOLOGY | ||
287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
288 | "Asking core to connect to `%s'\n", | ||
289 | GNUNET_i2s (peer)); | ||
290 | #endif | ||
280 | GNUNET_CORE_notify_transmit_ready (handle, | 291 | GNUNET_CORE_notify_transmit_ready (handle, |
281 | 0 /* priority */, | 292 | 0 /* priority */, |
282 | GNUNET_TIME_UNIT_MINUTES, | 293 | GNUNET_TIME_UNIT_MINUTES, |
@@ -300,7 +311,14 @@ is_friend (const struct GNUNET_PeerIdentity * peer) | |||
300 | { | 311 | { |
301 | if ( (GNUNET_YES == pos->is_friend) && | 312 | if ( (GNUNET_YES == pos->is_friend) && |
302 | (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity))) ) | 313 | (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity))) ) |
303 | return GNUNET_YES; | 314 | { |
315 | #if DEBUG_TOPOLOGY | ||
316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
317 | "Determined that `%s' is a friend\n", | ||
318 | GNUNET_i2s (peer)); | ||
319 | #endif | ||
320 | return GNUNET_YES; | ||
321 | } | ||
304 | pos = pos->next; | 322 | pos = pos->next; |
305 | } | 323 | } |
306 | return GNUNET_NO; | 324 | return GNUNET_NO; |
@@ -318,9 +336,21 @@ is_connection_allowed (const struct GNUNET_PeerIdentity * peer) | |||
318 | if (is_friend (peer)) | 336 | if (is_friend (peer)) |
319 | return GNUNET_OK; | 337 | return GNUNET_OK; |
320 | if (GNUNET_YES == friends_only) | 338 | if (GNUNET_YES == friends_only) |
321 | return GNUNET_SYSERR; | 339 | { |
340 | #if DEBUG_TOPOLOGY | ||
341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
342 | "Determined that `%s' is not allowed to connect (not a friend)\n", | ||
343 | GNUNET_i2s (peer)); | ||
344 | #endif | ||
345 | return GNUNET_SYSERR; | ||
346 | } | ||
322 | if (friend_count >= minimum_friend_count) | 347 | if (friend_count >= minimum_friend_count) |
323 | return GNUNET_OK; | 348 | return GNUNET_OK; |
349 | #if DEBUG_TOPOLOGY | ||
350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
351 | "Determined that `%s' is not allowed to connect (not enough connected friends)\n", | ||
352 | GNUNET_i2s (peer)); | ||
353 | #endif | ||
324 | return GNUNET_SYSERR; | 354 | return GNUNET_SYSERR; |
325 | } | 355 | } |
326 | 356 | ||
@@ -337,6 +367,11 @@ static void connect_notify (void *cls, | |||
337 | { | 367 | { |
338 | struct PeerList *pos; | 368 | struct PeerList *pos; |
339 | 369 | ||
370 | #if DEBUG_TOPOLOGY | ||
371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
372 | "Core told us that we connected to `%s'\n", | ||
373 | GNUNET_i2s (peer)); | ||
374 | #endif | ||
340 | connection_count++; | 375 | connection_count++; |
341 | pos = friends; | 376 | pos = friends; |
342 | while (pos != NULL) | 377 | while (pos != NULL) |
@@ -358,7 +393,14 @@ static void connect_notify (void *cls, | |||
358 | pos->next = friends; | 393 | pos->next = friends; |
359 | friends = pos; | 394 | friends = pos; |
360 | if (GNUNET_OK != is_connection_allowed (peer)) | 395 | if (GNUNET_OK != is_connection_allowed (peer)) |
361 | force_disconnect (peer); | 396 | { |
397 | #if DEBUG_TOPOLOGY | ||
398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
399 | "Connection to `%s' is forbidden, forcing disconnect!\n", | ||
400 | GNUNET_i2s (peer)); | ||
401 | #endif | ||
402 | force_disconnect (peer); | ||
403 | } | ||
362 | } | 404 | } |
363 | 405 | ||
364 | 406 | ||
@@ -376,6 +418,11 @@ drop_non_friends () | |||
376 | if (GNUNET_NO == pos->is_friend) | 418 | if (GNUNET_NO == pos->is_friend) |
377 | { | 419 | { |
378 | GNUNET_assert (GNUNET_YES == pos->is_connected); | 420 | GNUNET_assert (GNUNET_YES == pos->is_connected); |
421 | #if DEBUG_TOPOLOGY | ||
422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
423 | "Connection to `%s' is not from a friend, forcing disconnect!\n", | ||
424 | GNUNET_i2s (&pos->id)); | ||
425 | #endif | ||
379 | force_disconnect (&pos->id); | 426 | force_disconnect (&pos->id); |
380 | } | 427 | } |
381 | pos = pos->next; | 428 | pos = pos->next; |
@@ -395,7 +442,12 @@ static void disconnect_notify (void *cls, | |||
395 | { | 442 | { |
396 | struct PeerList *pos; | 443 | struct PeerList *pos; |
397 | struct PeerList *prev; | 444 | struct PeerList *prev; |
398 | 445 | ||
446 | #if DEBUG_TOPOLOGY | ||
447 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
448 | "Core told us that we disconnected from `%s'\n", | ||
449 | GNUNET_i2s (peer)); | ||
450 | #endif | ||
399 | connection_count--; | 451 | connection_count--; |
400 | pos = friends; | 452 | pos = friends; |
401 | prev = NULL; | 453 | prev = NULL; |
@@ -411,6 +463,10 @@ static void disconnect_notify (void *cls, | |||
411 | if (friend_count < minimum_friend_count) | 463 | if (friend_count < minimum_friend_count) |
412 | { | 464 | { |
413 | /* disconnect from all non-friends */ | 465 | /* disconnect from all non-friends */ |
466 | #if DEBUG_TOPOLOGY | ||
467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
468 | "Not enough friendly connections, dropping all non-friend connections\n"); | ||
469 | #endif | ||
414 | drop_non_friends (); | 470 | drop_non_friends (); |
415 | attempt_connect (peer, pos); | 471 | attempt_connect (peer, pos); |
416 | } | 472 | } |
@@ -461,6 +517,11 @@ schedule_peer_search () | |||
461 | (so roughly once a minute, plus the 15s minimum delay */ | 517 | (so roughly once a minute, plus the 15s minimum delay */ |
462 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 518 | delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
463 | 15 + 15 * 60 * connection_count * connection_count / target_connection_count / target_connection_count); | 519 | 15 + 15 * 60 * connection_count * connection_count / target_connection_count / target_connection_count); |
520 | #if DEBUG_TOPOLOGY | ||
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
522 | "Will try to find more peers in %llums\n", | ||
523 | (unsigned long long) delay.value); | ||
524 | #endif | ||
464 | GNUNET_SCHEDULER_add_delayed (sched, | 525 | GNUNET_SCHEDULER_add_delayed (sched, |
465 | GNUNET_NO, | 526 | GNUNET_NO, |
466 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 527 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
@@ -524,6 +585,12 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
524 | return; /* duplicate, at least "mostly" */ | 585 | return; /* duplicate, at least "mostly" */ |
525 | pos = pos->next; | 586 | pos = pos->next; |
526 | } | 587 | } |
588 | #if DEBUG_TOPOLOGY | ||
589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
590 | "Found `%s' from peer `%s' for advertising\n", | ||
591 | "HELLO", | ||
592 | GNUNET_i2s (&pid)); | ||
593 | #endif | ||
527 | size = GNUNET_HELLO_size (hello); | 594 | size = GNUNET_HELLO_size (hello); |
528 | pos = GNUNET_malloc (sizeof(struct HelloList) + size); | 595 | pos = GNUNET_malloc (sizeof(struct HelloList) + size); |
529 | pos->msg = (struct GNUNET_HELLO_Message*) &pos[1]; | 596 | pos->msg = (struct GNUNET_HELLO_Message*) &pos[1]; |
@@ -573,15 +640,34 @@ process_peer (void *cls, | |||
573 | return; /* that's me! */ | 640 | return; /* that's me! */ |
574 | 641 | ||
575 | consider_for_advertising (hello); | 642 | consider_for_advertising (hello); |
643 | #if DEBUG_TOPOLOGY | ||
644 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
645 | "Considering connecting to peer `%s'\n", | ||
646 | GNUNET_i2s (peer)); | ||
647 | #endif | ||
576 | pos = friends; | 648 | pos = friends; |
577 | while (pos != NULL) | 649 | while (pos != NULL) |
578 | { | 650 | { |
579 | if (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity))) | 651 | if (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity))) |
580 | { | 652 | { |
581 | if (GNUNET_YES == pos->is_connected) | 653 | if (GNUNET_YES == pos->is_connected) |
582 | return; | 654 | { |
655 | #if DEBUG_TOPOLOGY | ||
656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
657 | "Already connected to peer `%s'\n", | ||
658 | GNUNET_i2s (peer)); | ||
659 | #endif | ||
660 | return; | ||
661 | } | ||
583 | if (GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value > 0) | 662 | if (GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value > 0) |
584 | return; /* peer still blacklisted */ | 663 | { |
664 | #if DEBUG_TOPOLOGY | ||
665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
666 | "Already tried peer `%s' recently\n", | ||
667 | GNUNET_i2s (peer)); | ||
668 | #endif | ||
669 | return; /* peer still blacklisted */ | ||
670 | } | ||
585 | if (GNUNET_YES == pos->is_friend) | 671 | if (GNUNET_YES == pos->is_friend) |
586 | { | 672 | { |
587 | attempt_connect (peer, pos); | 673 | attempt_connect (peer, pos); |
@@ -590,10 +676,16 @@ process_peer (void *cls, | |||
590 | } | 676 | } |
591 | pos = pos->next; | 677 | pos = pos->next; |
592 | } | 678 | } |
593 | if (GNUNET_YES == friends_only) | 679 | if ( (GNUNET_YES == friends_only) || |
594 | return; | 680 | (friend_count < minimum_friend_count) ) |
595 | if (friend_count < minimum_friend_count) | 681 | { |
596 | return; | 682 | #if DEBUG_TOPOLOGY |
683 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
684 | "Peer `%s' is not a friend, and we currently only connect to friends\n", | ||
685 | GNUNET_i2s (peer)); | ||
686 | #endif | ||
687 | return; | ||
688 | } | ||
597 | attempt_connect (peer, NULL); | 689 | attempt_connect (peer, NULL); |
598 | } | 690 | } |
599 | 691 | ||
@@ -606,6 +698,10 @@ try_add_friends () | |||
606 | { | 698 | { |
607 | struct PeerList *pos; | 699 | struct PeerList *pos; |
608 | 700 | ||
701 | #if DEBUG_TOPOLOGY | ||
702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
703 | "Considering all of our friends for new connections\n"); | ||
704 | #endif | ||
609 | pos = friends; | 705 | pos = friends; |
610 | while (pos != NULL) | 706 | while (pos != NULL) |
611 | { | 707 | { |
@@ -639,6 +735,11 @@ discard_old_blacklist_entries () | |||
639 | (0 == GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value) ) | 735 | (0 == GNUNET_TIME_absolute_get_remaining (pos->blacklisted_until).value) ) |
640 | { | 736 | { |
641 | /* delete 'pos' from list */ | 737 | /* delete 'pos' from list */ |
738 | #if DEBUG_TOPOLOGY | ||
739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
740 | "Deleting peer `%s' from our list (not connected, not a friend and blacklist expired)\n", | ||
741 | GNUNET_i2s (&pos->id)); | ||
742 | #endif | ||
642 | if (prev == NULL) | 743 | if (prev == NULL) |
643 | friends = next; | 744 | friends = next; |
644 | else | 745 | else |
@@ -674,6 +775,13 @@ find_more_peers (void *cls, | |||
674 | schedule_peer_search (); | 775 | schedule_peer_search (); |
675 | return; | 776 | return; |
676 | } | 777 | } |
778 | #if DEBUG_TOPOLOGY | ||
779 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
780 | "Got sufficient (%u/%u, %u friends) number of connections, won't try to create more.\n", | ||
781 | connection_count, | ||
782 | target_connection_count, | ||
783 | friend_count); | ||
784 | #endif | ||
677 | GNUNET_PEERINFO_for_all (cfg, | 785 | GNUNET_PEERINFO_for_all (cfg, |
678 | sched, | 786 | sched, |
679 | NULL, | 787 | NULL, |
@@ -708,6 +816,11 @@ core_init (void *cls, | |||
708 | } | 816 | } |
709 | handle = server; | 817 | handle = server; |
710 | my_identity = *my_id; | 818 | my_identity = *my_id; |
819 | #if DEBUG_TOPOLOGY | ||
820 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
821 | "I am peer `%s'", | ||
822 | GNUNET_i2s (my_id)); | ||
823 | #endif | ||
711 | if (autoconnect) | 824 | if (autoconnect) |
712 | GNUNET_SCHEDULER_add_delayed (sched, | 825 | GNUNET_SCHEDULER_add_delayed (sched, |
713 | GNUNET_NO, | 826 | GNUNET_NO, |
@@ -819,6 +932,11 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
819 | fl->id.hashPubKey = hc; | 932 | fl->id.hashPubKey = hc; |
820 | fl->next = friends; | 933 | fl->next = friends; |
821 | friends = fl; | 934 | friends = fl; |
935 | #if DEBUG_TOPOLOGY | ||
936 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
937 | "Found friend `%s' in configuration\n", | ||
938 | GNUNET_i2s (&fl->id)); | ||
939 | #endif | ||
822 | } | 940 | } |
823 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); | 941 | pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); |
824 | while ((pos < frstat.st_size) && isspace (data[pos])) | 942 | while ((pos < frstat.st_size) && isspace (data[pos])) |
@@ -858,6 +976,12 @@ handle_encrypted_hello (void *cls, | |||
858 | const struct GNUNET_MessageHeader * | 976 | const struct GNUNET_MessageHeader * |
859 | message) | 977 | message) |
860 | { | 978 | { |
979 | #if DEBUG_TOPOLOGY | ||
980 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
981 | "Received encrypted `%s' from peer `%s'", | ||
982 | "HELLO", | ||
983 | GNUNET_i2s (other)); | ||
984 | #endif | ||
861 | if (transport != NULL) | 985 | if (transport != NULL) |
862 | GNUNET_TRANSPORT_offer_hello (transport, | 986 | GNUNET_TRANSPORT_offer_hello (transport, |
863 | message); | 987 | message); |
@@ -885,6 +1009,12 @@ gather_hello_callback (void *cls, | |||
885 | hello_gathering_active = GNUNET_NO; | 1009 | hello_gathering_active = GNUNET_NO; |
886 | return; | 1010 | return; |
887 | } | 1011 | } |
1012 | #if DEBUG_TOPOLOGY | ||
1013 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1014 | "Received `%s' for peer `%s'", | ||
1015 | "HELLO", | ||
1016 | GNUNET_i2s (peer)); | ||
1017 | #endif | ||
888 | if (hello != NULL) | 1018 | if (hello != NULL) |
889 | consider_for_advertising (hello); | 1019 | consider_for_advertising (hello); |
890 | } | 1020 | } |
@@ -915,6 +1045,12 @@ hello_advertising (void *cls, | |||
915 | struct HelloList *next; | 1045 | struct HelloList *next; |
916 | uint16_t size; | 1046 | uint16_t size; |
917 | 1047 | ||
1048 | #if DEBUG_TOPOLOGY | ||
1049 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1050 | "Data solicited for `%s', considering sending `%s's", | ||
1051 | GNUNET_i2s (receiver), | ||
1052 | "HELLO"); | ||
1053 | #endif | ||
918 | pl = friends; | 1054 | pl = friends; |
919 | while (pl != NULL) | 1055 | while (pl != NULL) |
920 | { | 1056 | { |
@@ -965,12 +1101,24 @@ hello_advertising (void *cls, | |||
965 | { | 1101 | { |
966 | size = 0; | 1102 | size = 0; |
967 | } | 1103 | } |
1104 | #if DEBUG_TOPOLOGY | ||
1105 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1106 | "Sending %u bytes of `%s's", | ||
1107 | (unsigned int) size, | ||
1108 | "HELLO"); | ||
1109 | #endif | ||
968 | return size; | 1110 | return size; |
969 | } | 1111 | } |
970 | if ( (GNUNET_NO == hello_gathering_active) && | 1112 | if ( (GNUNET_NO == hello_gathering_active) && |
971 | (GNUNET_TIME_absolute_get_duration (last_hello_gather_time).value > | 1113 | (GNUNET_TIME_absolute_get_duration (last_hello_gather_time).value > |
972 | MIN_HELLO_GATHER_DELAY.value) ) | 1114 | MIN_HELLO_GATHER_DELAY.value) ) |
973 | { | 1115 | { |
1116 | #if DEBUG_TOPOLOGY | ||
1117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1118 | "Have no `%s's, trying to get some from `%s' for next time", | ||
1119 | "HELLO", | ||
1120 | "PEERINFO"); | ||
1121 | #endif | ||
974 | hello_gathering_active = GNUNET_YES; | 1122 | hello_gathering_active = GNUNET_YES; |
975 | last_hello_gather_time = GNUNET_TIME_absolute_get(); | 1123 | last_hello_gather_time = GNUNET_TIME_absolute_get(); |
976 | GNUNET_PEERINFO_for_all (cfg, | 1124 | GNUNET_PEERINFO_for_all (cfg, |
@@ -1053,7 +1201,13 @@ run (void *cls, | |||
1053 | if ( (friends_only == GNUNET_YES) || | 1201 | if ( (friends_only == GNUNET_YES) || |
1054 | (minimum_friend_count > 0) ) | 1202 | (minimum_friend_count > 0) ) |
1055 | read_friends_file (cfg); | 1203 | read_friends_file (cfg); |
1056 | 1204 | #if DEBUG_TOPOLOGY | |
1205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1206 | "Topology would like %u connections with at least %u friends (%s)\n", | ||
1207 | target_connection_count, | ||
1208 | minimum_friend_count, | ||
1209 | autoconnect ? "autoconnect enabled" : "autoconnect disabled"); | ||
1210 | #endif | ||
1057 | transport = GNUNET_TRANSPORT_connect (sched, | 1211 | transport = GNUNET_TRANSPORT_connect (sched, |
1058 | cfg, | 1212 | cfg, |
1059 | NULL, | 1213 | NULL, |
diff --git a/src/topology/test_gnunet_service_topology.c b/src/topology/test_gnunet_service_topology.c index cc8792659..329b1fa5b 100644 --- a/src/topology/test_gnunet_service_topology.c +++ b/src/topology/test_gnunet_service_topology.c | |||
@@ -38,11 +38,40 @@ static int ok; | |||
38 | 38 | ||
39 | static int peers_left; | 39 | static int peers_left; |
40 | 40 | ||
41 | static int connect_left; | ||
42 | |||
41 | static struct GNUNET_TESTING_PeerGroup *pg; | 43 | static struct GNUNET_TESTING_PeerGroup *pg; |
42 | 44 | ||
45 | static struct GNUNET_TESTING_Daemon *first; | ||
46 | |||
47 | static struct GNUNET_TESTING_Daemon *last; | ||
48 | |||
43 | static struct GNUNET_SCHEDULER_Handle *sched; | 49 | static struct GNUNET_SCHEDULER_Handle *sched; |
44 | 50 | ||
45 | 51 | ||
52 | static void | ||
53 | notify_connect_complete(void *cls, | ||
54 | const char *emsg) | ||
55 | { | ||
56 | if (NULL != emsg) | ||
57 | { | ||
58 | fprintf (stderr, | ||
59 | "Failed to connect two peers: %s\n", | ||
60 | emsg); | ||
61 | GNUNET_assert (0); | ||
62 | return; | ||
63 | } | ||
64 | connect_left--; | ||
65 | if (connect_left == 0) | ||
66 | { | ||
67 | /* FIXME: check that topology adds a few more links | ||
68 | in addition to those that were seeded */ | ||
69 | GNUNET_TESTING_daemons_stop (pg); | ||
70 | ok = 0; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | |||
46 | static void my_cb(void *cls, | 75 | static void my_cb(void *cls, |
47 | const struct GNUNET_PeerIdentity *id, | 76 | const struct GNUNET_PeerIdentity *id, |
48 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 77 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -50,12 +79,23 @@ static void my_cb(void *cls, | |||
50 | const char *emsg) | 79 | const char *emsg) |
51 | { | 80 | { |
52 | GNUNET_assert (id != NULL); | 81 | GNUNET_assert (id != NULL); |
53 | peers_left--; | 82 | peers_left--; |
83 | if (first == NULL) | ||
84 | { | ||
85 | connect_left = NUM_PEERS; | ||
86 | first = d; | ||
87 | last = d; | ||
88 | return; | ||
89 | } | ||
90 | GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, | ||
91 | ¬ify_connect_complete, | ||
92 | NULL); | ||
54 | if (peers_left == 0) | 93 | if (peers_left == 0) |
55 | { | 94 | { |
56 | /* FIXME: connect a few... */ | 95 | /* close circle */ |
57 | GNUNET_TESTING_daemons_stop (pg); | 96 | GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, |
58 | ok = 0; | 97 | ¬ify_connect_complete, |
98 | NULL); | ||
59 | } | 99 | } |
60 | } | 100 | } |
61 | 101 | ||