aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-06-20 13:48:19 +0000
committerJulius Bünger <buenger@mytum.de>2015-06-20 13:48:19 +0000
commitc9f545f2ddd3fb733aa763b2d872f9ce35e2bccc (patch)
tree229b2f4cf41bff663d63b4602c73cc45360a69e6 /src/rps
parent870240d44941110248077d90eece173528c061cb (diff)
downloadgnunet-c9f545f2ddd3fb733aa763b2d872f9ce35e2bccc.tar.gz
gnunet-c9f545f2ddd3fb733aa763b2d872f9ce35e2bccc.zip
-restructured cleaning of known peers
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/gnunet-service-rps.c51
1 files changed, 26 insertions, 25 deletions
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)
923{ 923{
924 if (GNUNET_NO == in_arr (pull_list, pull_list_size, peer)) 924 if (GNUNET_NO == in_arr (pull_list, pull_list_size, peer))
925 GNUNET_array_append (pull_list, pull_list_size, *peer); 925 GNUNET_array_append (pull_list, pull_list_size, *peer);
926
927 peer_clean (peer);
928} 926}
929 927
930/** 928/**
@@ -2350,29 +2348,6 @@ process_peerinfo_peers (void *cls,
2350 2348
2351 2349
2352/** 2350/**
2353 * Clean the send channel of a peer
2354 */
2355void
2356peer_clean (const struct GNUNET_PeerIdentity *peer)
2357{
2358 struct PeerContext *peer_ctx;
2359 struct GNUNET_CADET_Channel *channel;
2360
2361 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_contains (view, peer) &&
2362 GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
2363 {
2364 peer_ctx = get_peer_ctx (peer_map, peer);
2365 if (NULL != peer_ctx->send_channel)
2366 {
2367 channel = peer_ctx->send_channel;
2368 peer_ctx->send_channel = NULL;
2369 GNUNET_CADET_channel_destroy (channel);
2370 }
2371 }
2372}
2373
2374
2375/**
2376 * Callback used to remove peers from the multipeermap. 2351 * Callback used to remove peers from the multipeermap.
2377 */ 2352 */
2378 int 2353 int
@@ -2454,6 +2429,32 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2454 2429
2455 2430
2456/** 2431/**
2432 * Clean the send channel of a peer
2433 * If there is also no channel to receive messages from that peer, remove it
2434 * from the peermap.
2435 */
2436void
2437peer_clean (const struct GNUNET_PeerIdentity *peer)
2438{
2439 struct PeerContext *peer_ctx;
2440 /* struct GNUNET_CADET_Channel *channel; */
2441
2442 if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_contains (view, peer) &&
2443 GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
2444 {
2445 peer_ctx = get_peer_ctx (peer_map, peer);
2446 GNUNET_CADET_channel_destroy (peer_ctx->send_channel);
2447 peer_ctx->send_channel = NULL;
2448
2449 if (NULL == peer_ctx->recv_channel)
2450 {
2451 peer_remove_cb (NULL, peer, peer_ctx);
2452 }
2453 }
2454}
2455
2456
2457/**
2457 * Task run during shutdown. 2458 * Task run during shutdown.
2458 * 2459 *
2459 * @param cls unused 2460 * @param cls unused