diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-06-05 16:38:22 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-06-05 16:38:22 +0000 |
commit | d5f446a9fef43b33d6fe04a97958ff91a8d91056 (patch) | |
tree | c948e693df8212ebf94821f55aa4e4f6b4b1f531 /src/topology/gnunet-daemon-topology.c | |
parent | 13ac535df012b9de42b1814d194a7610b9620525 (diff) | |
download | gnunet-d5f446a9fef43b33d6fe04a97958ff91a8d91056.tar.gz gnunet-d5f446a9fef43b33d6fe04a97958ff91a8d91056.zip |
fix
Diffstat (limited to 'src/topology/gnunet-daemon-topology.c')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 03699c174..bacd78324 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -194,6 +194,11 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
194 | static struct GNUNET_TRANSPORT_Blacklist *blacklist; | 194 | static struct GNUNET_TRANSPORT_Blacklist *blacklist; |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * Task scheduled to try to add peers. | ||
198 | */ | ||
199 | static GNUNET_SCHEDULER_TaskIdentifier add_task; | ||
200 | |||
201 | /** | ||
197 | * Flag to disallow non-friend connections (pure F2F mode). | 202 | * Flag to disallow non-friend connections (pure F2F mode). |
198 | */ | 203 | */ |
199 | static int friends_only; | 204 | static int friends_only; |
@@ -448,7 +453,8 @@ remove_from_greylist (void *cls, | |||
448 | pos); | 453 | pos); |
449 | } | 454 | } |
450 | if ( (GNUNET_NO == pos->is_friend) && | 455 | if ( (GNUNET_NO == pos->is_friend) && |
451 | (GNUNET_NO == pos->is_connected) ) | 456 | (GNUNET_NO == pos->is_connected) && |
457 | (NULL == pos->hello) ) | ||
452 | { | 458 | { |
453 | free_peer (NULL, &pos->pid.hashPubKey, pos); | 459 | free_peer (NULL, &pos->pid.hashPubKey, pos); |
454 | return; | 460 | return; |
@@ -526,8 +532,6 @@ hello_advertising_ready (void *cls, | |||
526 | void *buf); | 532 | void *buf); |
527 | 533 | ||
528 | 534 | ||
529 | |||
530 | |||
531 | /** | 535 | /** |
532 | * Closure for 'find_advertisable_hello'. | 536 | * Closure for 'find_advertisable_hello'. |
533 | */ | 537 | */ |
@@ -762,6 +766,24 @@ try_add_peers (void *cls, | |||
762 | 766 | ||
763 | 767 | ||
764 | /** | 768 | /** |
769 | * Last task run during shutdown. Disconnects us from | ||
770 | * the transport and core. | ||
771 | * | ||
772 | * @param cls unused, NULL | ||
773 | * @param tc scheduler context | ||
774 | */ | ||
775 | static void | ||
776 | add_peer_task (void *cls, | ||
777 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
778 | { | ||
779 | add_task = GNUNET_SCHEDULER_NO_TASK; | ||
780 | |||
781 | GNUNET_CONTAINER_multihashmap_iterate (peers, | ||
782 | &try_add_peers, | ||
783 | NULL); | ||
784 | } | ||
785 | |||
786 | /** | ||
765 | * Method called whenever a peer disconnects. | 787 | * Method called whenever a peer disconnects. |
766 | * | 788 | * |
767 | * @param cls closure | 789 | * @param cls closure |
@@ -807,11 +829,10 @@ disconnect_notify (void *cls, | |||
807 | friend_count, | 829 | friend_count, |
808 | GNUNET_NO); | 830 | GNUNET_NO); |
809 | } | 831 | } |
810 | if ( (connection_count < target_connection_count) || | 832 | if ( ( (connection_count < target_connection_count) || |
811 | (friend_count < minimum_friend_count) ) | 833 | (friend_count < minimum_friend_count) ) && |
812 | GNUNET_CONTAINER_multihashmap_iterate (peers, | 834 | (GNUNET_SCHEDULER_NO_TASK == add_task) ) |
813 | &try_add_peers, | 835 | add_task = GNUNET_SCHEDULER_add_now (&add_peer_task, NULL); |
814 | NULL); | ||
815 | if ( (friend_count < minimum_friend_count) && | 836 | if ( (friend_count < minimum_friend_count) && |
816 | (blacklist == NULL) ) | 837 | (blacklist == NULL) ) |
817 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, | 838 | blacklist = GNUNET_TRANSPORT_blacklist (cfg, |
@@ -936,12 +957,15 @@ process_peer (void *cls, | |||
936 | struct Peer *pos; | 957 | struct Peer *pos; |
937 | 958 | ||
938 | if (err_msg != NULL) | 959 | if (err_msg != NULL) |
939 | { | 960 | { |
940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 961 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
941 | _("Error in communication with PEERINFO service\n")); | 962 | _("Error in communication with PEERINFO service: %s\n"), |
942 | /* return; */ | 963 | err_msg); |
943 | } | 964 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); |
944 | 965 | peerinfo_notify = GNUNET_PEERINFO_notify (cfg, &process_peer, | |
966 | NULL); | ||
967 | return; | ||
968 | } | ||
945 | GNUNET_assert (peer != NULL); | 969 | GNUNET_assert (peer != NULL); |
946 | if (0 == memcmp (&my_identity, | 970 | if (0 == memcmp (&my_identity, |
947 | peer, sizeof (struct GNUNET_PeerIdentity))) | 971 | peer, sizeof (struct GNUNET_PeerIdentity))) |
@@ -1305,6 +1329,11 @@ cleaning_task (void *cls, | |||
1305 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); | 1329 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify); |
1306 | peerinfo_notify = NULL; | 1330 | peerinfo_notify = NULL; |
1307 | } | 1331 | } |
1332 | if (GNUNET_SCHEDULER_NO_TASK != add_task) | ||
1333 | { | ||
1334 | GNUNET_SCHEDULER_cancel (add_task); | ||
1335 | add_task = GNUNET_SCHEDULER_NO_TASK; | ||
1336 | } | ||
1308 | GNUNET_TRANSPORT_disconnect (transport); | 1337 | GNUNET_TRANSPORT_disconnect (transport); |
1309 | transport = NULL; | 1338 | transport = NULL; |
1310 | GNUNET_CONTAINER_multihashmap_iterate (peers, | 1339 | GNUNET_CONTAINER_multihashmap_iterate (peers, |