aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-06-05 23:03:10 +0000
committerJulius Bünger <buenger@mytum.de>2015-06-05 23:03:10 +0000
commit98999c49cb59860ad494afbc225ec13e54db571f (patch)
treed8774f5bd610593169a2a337ca34da17af57fea0 /src
parentf7de514efc0292b993fe2935d7b0cb9499833ed0 (diff)
downloadgnunet-98999c49cb59860ad494afbc225ec13e54db571f.tar.gz
gnunet-98999c49cb59860ad494afbc225ec13e54db571f.zip
-tried to fix channel cleanups
Diffstat (limited to 'src')
-rw-r--r--src/rps/gnunet-service-rps.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index bc0468fd9..83e06c2eb 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -97,7 +97,14 @@ enum PeerFlags
97 /** 97 /**
98 * We set this bit when we can be sure the other peer is/was live. 98 * We set this bit when we can be sure the other peer is/was live.
99 */ 99 */
100 VALID = 0x10 100 VALID = 0x10,
101
102 /**
103 * We set this bit when we are going to destroy the channel to this peer.
104 * When cleanup_channel is called, we know that we wanted to destroy it.
105 * Otherwise the channel to the other peer was destroyed.
106 */
107 TO_DESTROY = 0x20,
101}; 108};
102 109
103 110
@@ -2278,6 +2285,7 @@ peer_remove_cb (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
2278 if (NULL != send 2285 if (NULL != send
2279 && channel != send) 2286 && channel != send)
2280 { 2287 {
2288 set_peer_flag (peer_ctx, TO_DESTROY);
2281 GNUNET_CADET_channel_destroy (send); 2289 GNUNET_CADET_channel_destroy (send);
2282 } 2290 }
2283 else 2291 else
@@ -2433,13 +2441,22 @@ cleanup_channel (void *cls,
2433 if (NULL == peer_ctx) /* It could have been removed by shutdown_task */ 2441 if (NULL == peer_ctx) /* It could have been removed by shutdown_task */
2434 return; 2442 return;
2435 2443
2444
2436 if (channel == peer_ctx->send_channel) 2445 if (channel == peer_ctx->send_channel)
2437 { /* Peer went down or we killd the channel */ 2446 { /* Something (but us) killd the channel */
2438 LOG (GNUNET_ERROR_TYPE_DEBUG, 2447 LOG (GNUNET_ERROR_TYPE_DEBUG,
2439 "send channel (%s) was destroyed - cleaning up\n", 2448 "send channel (%s) was destroyed - cleaning up\n",
2440 GNUNET_i2s (peer)); 2449 GNUNET_i2s (peer));
2441 rem_from_list (&gossip_list, &gossip_list_size, peer); 2450
2442 rem_from_list (&pending_pull_reply_list, &pending_pull_reply_list_size, peer); 2451 rem_from_list (&gossip_list,
2452 &gossip_list_size,
2453 peer);
2454 rem_from_list (&pending_pull_reply_list,
2455 &pending_pull_reply_list_size,
2456 peer);
2457 to_file (file_name_view_log,
2458 "-%s\t(cleanup channel, other peer)",
2459 GNUNET_i2s_full (peer));
2443 2460
2444 peer_ctx->send_channel = NULL; 2461 peer_ctx->send_channel = NULL;
2445 /* Somwewhat {ab,re}use the iterator function */ 2462 /* Somwewhat {ab,re}use the iterator function */
@@ -2458,6 +2475,33 @@ cleanup_channel (void *cls,
2458 GNUNET_i2s (peer)); 2475 GNUNET_i2s (peer));
2459 peer_ctx->recv_channel = NULL; 2476 peer_ctx->recv_channel = NULL;
2460 } 2477 }
2478 else if (NULL == peer_ctx->send_channel &&
2479 get_peer_flag (peer_ctx, TO_DESTROY))
2480 { /* We closed the channel to that peer */
2481 LOG (GNUNET_ERROR_TYPE_DEBUG,
2482 "send channel (%s) was destroyed by us - cleaning up\n",
2483 GNUNET_i2s (peer));
2484
2485 rem_from_list (&gossip_list,
2486 &gossip_list_size,
2487 peer);
2488 rem_from_list (&pending_pull_reply_list,
2489 &pending_pull_reply_list_size,
2490 peer);
2491 to_file (file_name_view_log,
2492 "-%s\t(cleanup channel, ourself)",
2493 GNUNET_i2s_full (peer));
2494
2495 /* Somwewhat {ab,re}use the iterator function */
2496 /* Cast to void is ok, because it's used as void in peer_remove_cb */
2497 (void) peer_remove_cb ((void *) channel, peer, peer_ctx);
2498 }
2499 else
2500 {
2501 LOG (GNUNET_ERROR_TYPE_WARNING,
2502 "unknown channel (%s) was destroyed\n",
2503 GNUNET_i2s (peer));
2504 }
2461 //} 2505 //}
2462} 2506}
2463 2507
@@ -2569,7 +2613,7 @@ run (void *cls,
2569 size, 2613 size,
2570 out_size); 2614 out_size);
2571 } 2615 }
2572 2616
2573 2617
2574 /* connect to NSE */ 2618 /* connect to NSE */
2575 nse = GNUNET_NSE_connect (cfg, nse_callback, NULL); 2619 nse = GNUNET_NSE_connect (cfg, nse_callback, NULL);