aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet-new_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet-new_peer.c')
-rw-r--r--src/cadet/gnunet-service-cadet-new_peer.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/cadet/gnunet-service-cadet-new_peer.c b/src/cadet/gnunet-service-cadet-new_peer.c
index fa1cc9ed9..1505914a1 100644
--- a/src/cadet/gnunet-service-cadet-new_peer.c
+++ b/src/cadet/gnunet-service-cadet-new_peer.c
@@ -40,7 +40,6 @@
40#include "gnunet_core_service.h" 40#include "gnunet_core_service.h"
41#include "gnunet_statistics_service.h" 41#include "gnunet_statistics_service.h"
42#include "cadet_protocol.h" 42#include "cadet_protocol.h"
43#include "cadet_path.h"
44#include "gnunet-service-cadet-new.h" 43#include "gnunet-service-cadet-new.h"
45#include "gnunet-service-cadet-new_connection.h" 44#include "gnunet-service-cadet-new_connection.h"
46#include "gnunet-service-cadet-new_dht.h" 45#include "gnunet-service-cadet-new_dht.h"
@@ -257,7 +256,8 @@ destroy_peer (void *cls)
257 cp->destroy_task = NULL; 256 cp->destroy_task = NULL;
258 GNUNET_assert (NULL == cp->t); 257 GNUNET_assert (NULL == cp->t);
259 GNUNET_assert (NULL == cp->core_mq); 258 GNUNET_assert (NULL == cp->core_mq);
260 GNUNET_assert (0 == cp->path_dll_length); 259 for (unsigned int i=0;i<cp->path_dll_length;i++)
260 GNUNET_assert (NULL == cp->path_heads[i]);
261 GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections)); 261 GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections));
262 GNUNET_assert (GNUNET_YES == 262 GNUNET_assert (GNUNET_YES ==
263 GNUNET_CONTAINER_multipeermap_remove (peers, 263 GNUNET_CONTAINER_multipeermap_remove (peers,
@@ -284,7 +284,11 @@ destroy_peer (void *cls)
284 cp->connectivity_suggestion = NULL; 284 cp->connectivity_suggestion = NULL;
285 } 285 }
286 GNUNET_CONTAINER_multishortmap_destroy (cp->connections); 286 GNUNET_CONTAINER_multishortmap_destroy (cp->connections);
287 GNUNET_CONTAINER_heap_destroy (cp->path_heap); 287 if (NULL != cp->path_heap)
288 {
289 GNUNET_CONTAINER_heap_destroy (cp->path_heap);
290 cp->path_heap = NULL;
291 }
288 GNUNET_free_non_null (cp->hello); 292 GNUNET_free_non_null (cp->hello);
289 /* Peer should not be freed if paths exist; if there are no paths, 293 /* Peer should not be freed if paths exist; if there are no paths,
290 there ought to be no connections, and without connections, no 294 there ought to be no connections, and without connections, no
@@ -418,8 +422,9 @@ consider_peer_destroy (struct CadetPeer *cp)
418 cp); 422 cp);
419 return; 423 return;
420 } 424 }
421 if (0 < cp->path_dll_length) 425 for (unsigned int i=0;i<cp->path_dll_length;i++)
422 return; /* still relevant! */ 426 if (NULL != cp->path_heads[i])
427 return; /* still relevant! */
423 if (NULL != cp->hello) 428 if (NULL != cp->hello)
424 { 429 {
425 /* relevant only until HELLO expires */ 430 /* relevant only until HELLO expires */
@@ -628,6 +633,28 @@ GCP_destroy_all_peers ()
628 633
629 634
630/** 635/**
636 * Drop all paths owned by this peer, and do not
637 * allow new ones to be added: We are shutting down.
638 *
639 * @param cp peer to drop paths to
640 */
641void
642GCP_drop_owned_paths (struct CadetPeer *cp)
643{
644 struct CadetPeerPath *path;
645
646 LOG (GNUNET_ERROR_TYPE_DEBUG,
647 "Destroying all paths to %s\n",
648 GCP_2s (cp));
649 while (NULL != (path =
650 GNUNET_CONTAINER_heap_remove_root (cp->path_heap)))
651 GCPP_release (path);
652 GNUNET_CONTAINER_heap_destroy (cp->path_heap);
653 cp->path_heap = NULL;
654}
655
656
657/**
631 * Add an entry to the DLL of all of the paths that this peer is on. 658 * Add an entry to the DLL of all of the paths that this peer is on.
632 * 659 *
633 * @param cp peer to modify 660 * @param cp peer to modify
@@ -730,6 +757,12 @@ GCP_attach_path (struct CadetPeer *cp,
730 GNUNET_CONTAINER_HeapCostType root_desirability; 757 GNUNET_CONTAINER_HeapCostType root_desirability;
731 struct GNUNET_CONTAINER_HeapNode *hn; 758 struct GNUNET_CONTAINER_HeapNode *hn;
732 759
760 if (NULL == cp->path_heap)
761 {
762 /* #GCP_drop_owned_paths() was already called, we cannot take new ones! */
763 GNUNET_assert (GNUNET_NO == force);
764 return NULL;
765 }
733 desirability = GCPP_get_desirability (path); 766 desirability = GCPP_get_desirability (path);
734 if (GNUNET_NO == force) 767 if (GNUNET_NO == force)
735 { 768 {