}
+/**
+ * Callback invoked on all peers to destroy all tunnels
+ * that may still exist.
+ *
+ * @param cls NULL
+ * @param pid identify of a peer
+ * @param value a `struct CadetPeer` that may still have a tunnel
+ * @return #GNUNET_OK (iterate over all entries)
+ */
+static int
+destroy_paths_now (void *cls,
+ const struct GNUNET_PeerIdentity *pid,
+ void *value)
+{
+ struct CadetPeer *cp = value;
+
+ GCP_drop_owned_paths (cp);
+ return GNUNET_OK;
+}
+
+
/**
* Task run during shutdown.
*
GCP_iterate_all (&destroy_tunnels_now,
NULL);
/* All tunnels, channels, connections and CORE must be down before this point. */
+ GCP_iterate_all (&destroy_paths_now,
+ NULL);
+ /* All paths, tunnels, channels, connections and CORE must be down before this point. */
GCP_destroy_all_peers ();
if (NULL != peers)
{
GNUNET_sh2s (&msg->cid.connection_of_tunnel));
path = GCPP_get_path_from_route (path_length - 1,
pids);
- GCT_add_inbound_connection (GCT_create_tunnel (origin),
+ GCT_add_inbound_connection (GCP_get_tunnel (origin,
+ GNUNET_YES),
&msg->cid,
path);
return;
*/
struct GNUNET_CONTAINER_HeapNode *hn;
- /**
- * Connections using this path, by destination peer
- * (each hop of the path could correspond to an
- * active connection).
- */
- struct GNUNET_CONTAINER_MultiPeerMap *connections;
-
/**
* Desirability of the path. How unique is it for the various peers
* on it?
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Destroying path %s\n",
GCPP_2s (path));
- GNUNET_assert (0 ==
- GNUNET_CONTAINER_multipeermap_size (path->connections));
- GNUNET_CONTAINER_multipeermap_destroy (path->connections);
for (unsigned int i=0;i<path->entries_length;i++)
GNUNET_free (path->entries[i]);
GNUNET_free (path->entries);
entry = path->entries[path->entries_length - 1];
while (1)
{
- /* cut 'off' end of path, verifying it is not in use */
- GNUNET_assert (NULL ==
- GNUNET_CONTAINER_multipeermap_get (path->connections,
- GCP_get_id (entry->peer)));
+ /* cut 'off' end of path */
GCP_path_entry_remove (entry->peer,
entry,
path->entries_length - 1);
#include "gnunet_core_service.h"
#include "gnunet_statistics_service.h"
#include "cadet_protocol.h"
-#include "cadet_path.h"
#include "gnunet-service-cadet-new.h"
#include "gnunet-service-cadet-new_connection.h"
#include "gnunet-service-cadet-new_dht.h"
cp->destroy_task = NULL;
GNUNET_assert (NULL == cp->t);
GNUNET_assert (NULL == cp->core_mq);
- GNUNET_assert (0 == cp->path_dll_length);
+ for (unsigned int i=0;i<cp->path_dll_length;i++)
+ GNUNET_assert (NULL == cp->path_heads[i]);
GNUNET_assert (0 == GNUNET_CONTAINER_multishortmap_size (cp->connections));
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (peers,
cp->connectivity_suggestion = NULL;
}
GNUNET_CONTAINER_multishortmap_destroy (cp->connections);
- GNUNET_CONTAINER_heap_destroy (cp->path_heap);
+ if (NULL != cp->path_heap)
+ {
+ GNUNET_CONTAINER_heap_destroy (cp->path_heap);
+ cp->path_heap = NULL;
+ }
GNUNET_free_non_null (cp->hello);
/* Peer should not be freed if paths exist; if there are no paths,
there ought to be no connections, and without connections, no
cp);
return;
}
- if (0 < cp->path_dll_length)
- return; /* still relevant! */
+ for (unsigned int i=0;i<cp->path_dll_length;i++)
+ if (NULL != cp->path_heads[i])
+ return; /* still relevant! */
if (NULL != cp->hello)
{
/* relevant only until HELLO expires */
}
+/**
+ * Drop all paths owned by this peer, and do not
+ * allow new ones to be added: We are shutting down.
+ *
+ * @param cp peer to drop paths to
+ */
+void
+GCP_drop_owned_paths (struct CadetPeer *cp)
+{
+ struct CadetPeerPath *path;
+
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Destroying all paths to %s\n",
+ GCP_2s (cp));
+ while (NULL != (path =
+ GNUNET_CONTAINER_heap_remove_root (cp->path_heap)))
+ GCPP_release (path);
+ GNUNET_CONTAINER_heap_destroy (cp->path_heap);
+ cp->path_heap = NULL;
+}
+
+
/**
* Add an entry to the DLL of all of the paths that this peer is on.
*
GNUNET_CONTAINER_HeapCostType root_desirability;
struct GNUNET_CONTAINER_HeapNode *hn;
+ if (NULL == cp->path_heap)
+ {
+ /* #GCP_drop_owned_paths() was already called, we cannot take new ones! */
+ GNUNET_assert (GNUNET_NO == force);
+ return NULL;
+ }
desirability = GCPP_get_desirability (path);
if (GNUNET_NO == force)
{
GCP_count_paths (const struct CadetPeer *cp);
+/**
+ * Drop all paths owned by this peer, and do not
+ * allow new ones to be added: We are shutting down.
+ *
+ * @param cp peer to drop paths to
+ */
+void
+GCP_drop_owned_paths (struct CadetPeer *cp);
+
+
/**
* Peer path iterator.
*
{
GNUNET_assert (0 ==
GNUNET_CONTAINER_multihashmap32_size (t->channels));
- GNUNET_SCHEDULER_cancel (t->destroy_task);
+ if (NULL != t->destroy_task)
+ {
+ GNUNET_SCHEDULER_cancel (t->destroy_task);
+ t->destroy_task = NULL;
+ }
destroy_tunnel (t);
}