From 9e2d093fbc96354affbc51f9d21b5f5593b348a1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 Jan 2010 12:08:39 +0000 Subject: [PATCH] fix hang, use notifications --- src/topology/gnunet-daemon-topology.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index d9f5e0ef2..f63cc0d85 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2007, 2008, 2009 Christian Grothoff (and other contributing authors) + (C) 2007, 2008, 2009, 2010 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -138,6 +138,14 @@ struct HelloList }; +/** + * Our peerinfo notification context. We use notification + * to instantly learn about new peers as they are discovered + * as well as periodic iteration to try peers again after + * a while. + */ +static struct GNUNET_PEERINFO_NotifyContext *peerinfo_notify; + /** * Linked list of HELLOs for advertising. */ @@ -270,6 +278,7 @@ attempt_connect (const struct GNUNET_PeerIdentity *peer, { if (0 == memcmp (&pos->id, peer, sizeof (struct GNUNET_PeerIdentity))) break; + pos = pos->next; } } if (pos == NULL) @@ -1151,6 +1160,11 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { struct PeerList *pl; + if (NULL != peerinfo_notify) + { + GNUNET_PEERINFO_notify_cancel (peerinfo_notify); + peerinfo_notify = NULL; + } GNUNET_TRANSPORT_disconnect (transport); transport = NULL; if (handle != NULL) @@ -1162,7 +1176,7 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { friends = pl->next; GNUNET_free (pl); - } + } } @@ -1258,6 +1272,9 @@ run (void *cls, GNUNET_SCHEDULER_shutdown (sched); return; } + peerinfo_notify = GNUNET_PEERINFO_notify (cfg, sched, + &process_peer, + NULL); } -- 2.25.1