From: Christian Grothoff Date: Sun, 7 Aug 2011 14:29:39 +0000 (+0000) Subject: stuff X-Git-Tag: initial-import-from-subversion-38251~17417 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f0161e3832d1a99c559f647e27c8ff073b88b13c;p=oweals%2Fgnunet.git stuff --- diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index db2a40a70..a8302bc56 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c @@ -321,8 +321,12 @@ disconnect_neighbour (struct NeighbourMapEntry *n) { struct MessageQueue *mq; - disconnect_notify_cb (callback_cls, - &n->id); + if (n->is_connected) + { + disconnect_notify_cb (callback_cls, + &n->id); + n->is_connected = GNUNET_NO; + } GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove (neighbours, &n->id.hashPubKey, @@ -666,6 +670,23 @@ GST_neighbours_iterate (GST_NeighbourIterator cb, } +/** + * Peer has been idle for too long. Disconnect. + * + * @param cls the 'struct NeighbourMapEntry' of the neighbour that went idle + * @param tc scheduler context + */ +static void +neighbour_idle_timeout_task (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct NeighbourMapEntry *n = cls; + + n->timeout_task = GNUNET_SCHEDULER_NO_TASK; + disconnect_neighbour (n); +} + + /** * We have received a CONNECT. Set the peer to connected. * @@ -697,7 +718,7 @@ GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender, { GNUNET_break (0); return GNUNET_SYSERR; - } + } n = lookup_neighbour (sender); if ( (NULL != n) || (n->is_connected == GNUNET_YES) ) @@ -745,7 +766,13 @@ GST_neighbours_handle_connect (const struct GNUNET_PeerIdentity *sender, // FIXME: ATS: switch session!? // n->session = session; } - n->is_connected = GNUNET_YES; + n->peer_timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); + if (GNUNET_SCHEDULER_NO_TASK != n->timeout_task) + GNUNET_SCHEDULER_cancel (n->timeout_task); + n->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, + &neighbour_idle_timeout_task, + n); + n->is_connected = GNUNET_YES; connect_notify_cb (callback_cls, sender, n->ats, diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index db6f03dc5..76edf1891 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -32,6 +32,7 @@ #include "gnunet_peerinfo_service.h" #include "gnunet_signatures.h" +// TODO: send our HELLO with the PING! /** * How long is a PONG signature valid? We'll recycle a signature until