From c9f545f2ddd3fb733aa763b2d872f9ce35e2bccc Mon Sep 17 00:00:00 2001 From: Julius Bünger Date: Sat, 20 Jun 2015 13:48:19 +0000 Subject: -restructured cleaning of known peers --- src/rps/gnunet-service-rps.c | 51 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src/rps') diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 63c9dcffa..34501937d 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c @@ -923,8 +923,6 @@ insert_in_pull_list (void *cls, const struct GNUNET_PeerIdentity *peer) { if (GNUNET_NO == in_arr (pull_list, pull_list_size, peer)) GNUNET_array_append (pull_list, pull_list_size, *peer); - - peer_clean (peer); } /** @@ -2349,29 +2347,6 @@ process_peerinfo_peers (void *cls, } -/** - * Clean the send channel of a peer - */ -void -peer_clean (const struct GNUNET_PeerIdentity *peer) -{ - struct PeerContext *peer_ctx; - struct GNUNET_CADET_Channel *channel; - - if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_contains (view, peer) && - GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) - { - peer_ctx = get_peer_ctx (peer_map, peer); - if (NULL != peer_ctx->send_channel) - { - channel = peer_ctx->send_channel; - peer_ctx->send_channel = NULL; - GNUNET_CADET_channel_destroy (channel); - } - } -} - - /** * Callback used to remove peers from the multipeermap. */ @@ -2453,6 +2428,32 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value) } +/** + * Clean the send channel of a peer + * If there is also no channel to receive messages from that peer, remove it + * from the peermap. + */ +void +peer_clean (const struct GNUNET_PeerIdentity *peer) +{ + struct PeerContext *peer_ctx; + /* struct GNUNET_CADET_Channel *channel; */ + + if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_contains (view, peer) && + GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) + { + peer_ctx = get_peer_ctx (peer_map, peer); + GNUNET_CADET_channel_destroy (peer_ctx->send_channel); + peer_ctx->send_channel = NULL; + + if (NULL == peer_ctx->recv_channel) + { + peer_remove_cb (NULL, peer, peer_ctx); + } + } +} + + /** * Task run during shutdown. * -- cgit v1.2.3