gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (4c56d5a0f -> f74bc79fc)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (4c56d5a0f -> f74bc79fc)
Date: Sun, 22 Jan 2017 16:33:04 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 4c56d5a0f must not move location of -struct CadetPeerPathEntry- in 
memory when growing path length as those structs are also referenced from a DLL
     new 4f1c17f65 fix comparisson
     new ceb48e10d nicer logging
     new f74bc79fc fix shutdown logic

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cadet/gnunet-service-cadet-new.c            |  24 +++++
 src/cadet/gnunet-service-cadet-new_connection.c |   5 +-
 src/cadet/gnunet-service-cadet-new_core.c       |   3 +-
 src/cadet/gnunet-service-cadet-new_paths.c      |  32 ++++---
 src/cadet/gnunet-service-cadet-new_peer.c       |  55 +++++++++--
 src/cadet/gnunet-service-cadet-new_peer.h       |  10 ++
 src/cadet/gnunet-service-cadet-new_tunnels.c    | 122 ++++++++++++------------
 7 files changed, 167 insertions(+), 84 deletions(-)

diff --git a/src/cadet/gnunet-service-cadet-new.c 
b/src/cadet/gnunet-service-cadet-new.c
index b0d8fc32d..2e431c034 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -335,6 +335,27 @@ destroy_tunnels_now (void *cls,
 
 
 /**
+ * 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.
  *
  * @param cls unused
@@ -366,6 +387,9 @@ shutdown_task (void *cls)
   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)
   {
diff --git a/src/cadet/gnunet-service-cadet-new_connection.c 
b/src/cadet/gnunet-service-cadet-new_connection.c
index 3d0b96fcf..9b0a2f13b 100644
--- a/src/cadet/gnunet-service-cadet-new_connection.c
+++ b/src/cadet/gnunet-service-cadet-new_connection.c
@@ -210,9 +210,10 @@ void
 GCC_handle_connection_create_ack (struct CadetConnection *cc)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Received CREATE_ACK for connection %s in state %d\n",
+       "Received CREATE_ACK for connection %s in state %d (%s)\n",
        GCC_2s (cc),
-       cc->state);
+       cc->state,
+       (GNUNET_YES == cc->mqm_ready) ? "MQM ready" : "MQM busy");
   if (NULL != cc->task)
   {
     GNUNET_SCHEDULER_cancel (cc->task);
diff --git a/src/cadet/gnunet-service-cadet-new_core.c 
b/src/cadet/gnunet-service-cadet-new_core.c
index 7cff68f4a..1e35a5102 100644
--- a/src/cadet/gnunet-service-cadet-new_core.c
+++ b/src/cadet/gnunet-service-cadet-new_core.c
@@ -476,7 +476,8 @@ handle_connection_create (void *cls,
          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;
diff --git a/src/cadet/gnunet-service-cadet-new_paths.c 
b/src/cadet/gnunet-service-cadet-new_paths.c
index 1c648462d..39658d4e8 100644
--- a/src/cadet/gnunet-service-cadet-new_paths.c
+++ b/src/cadet/gnunet-service-cadet-new_paths.c
@@ -55,13 +55,6 @@ struct CadetPeerPath
   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?
    */
@@ -185,9 +178,6 @@ path_destroy (struct CadetPeerPath *path)
   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);
@@ -214,10 +204,7 @@ GCPP_release (struct CadetPeerPath *path)
   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);
@@ -324,12 +311,29 @@ check_match (void *cls,
   GNUNET_assert (path->entries_length > off);
   if ( (path->entries_length != off + 1) &&
        (off + 1 != cm_ctx->cpath_length) )
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "check_match missmatch because path %s is too long (%u vs. %u vs. 
%u)\n",
+         GCPP_2s (path),
+         path->entries_length,
+         off + 1,
+         cm_ctx->cpath_length);
     return GNUNET_YES; /* too long, goes somewhere else already, thus cannot 
be useful */
+  }
   for (unsigned int i=0;i<off;i++)
     if (cm_ctx->cpath[i] !=
         GCPP_get_peer_at_offset (path,
                                  i))
+    {
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "check_match path %s missmatches at offset %u\n",
+           GCPP_2s (path),
+           i);
       return GNUNET_YES; /* missmatch, ignore */
+    }
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "check_match found match with path %s\n",
+       GCPP_2s (path));
   cm_ctx->match = path;
   return GNUNET_NO; /* match, we are done! */
 }
diff --git a/src/cadet/gnunet-service-cadet-new_peer.c 
b/src/cadet/gnunet-service-cadet-new_peer.c
index 39645c909..1505914a1 100644
--- a/src/cadet/gnunet-service-cadet-new_peer.c
+++ b/src/cadet/gnunet-service-cadet-new_peer.c
@@ -40,7 +40,6 @@
 #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"
@@ -257,7 +256,8 @@ destroy_peer (void *cls)
   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,
@@ -284,7 +284,11 @@ destroy_peer (void *cls)
     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
@@ -418,8 +422,9 @@ consider_peer_destroy (struct CadetPeer *cp)
                                                      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 */
@@ -628,6 +633,28 @@ GCP_destroy_all_peers ()
 
 
 /**
+ * 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.
  *
  * @param cp peer to modify
@@ -730,6 +757,12 @@ GCP_attach_path (struct CadetPeer *cp,
   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)
   {
@@ -755,7 +788,7 @@ GCP_attach_path (struct CadetPeer *cp,
   }
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Attaching path %p to peer %s (%s)\n",
+       "Attaching path %s to peer %s (%s)\n",
        GCPP_2s (path),
        GCP_2s (cp),
        (GNUNET_NO == force) ? "desirable" : "forced");
@@ -806,7 +839,7 @@ GCP_detach_path (struct CadetPeer *cp,
                  struct GNUNET_CONTAINER_HeapNode *hn)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Detatching path %p from peer %s\n",
+       "Detatching path %s from peer %s\n",
        GCPP_2s (path),
        GCP_2s (cp));
   GNUNET_assert (path ==
@@ -1007,8 +1040,14 @@ GCP_iterate_paths_at (struct CadetPeer *cp,
 {
   unsigned int ret = 0;
 
-  if (dist <= cp->path_dll_length)
+  if (dist >= cp->path_dll_length)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Asked to look for paths at distance %u, but maximum for me is < 
%u\n",
+         dist,
+         cp->path_dll_length);
     return 0;
+  }
   for (struct CadetPeerPathEntry *pe = cp->path_heads[dist];
        NULL != pe;
        pe = pe->next)
diff --git a/src/cadet/gnunet-service-cadet-new_peer.h 
b/src/cadet/gnunet-service-cadet-new_peer.h
index 8a1d3ed5c..aaaef15b8 100644
--- a/src/cadet/gnunet-service-cadet-new_peer.h
+++ b/src/cadet/gnunet-service-cadet-new_peer.h
@@ -91,6 +91,16 @@ 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.
  *
  * @param cls Closure.
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c 
b/src/cadet/gnunet-service-cadet-new_tunnels.c
index d63da29d4..a1a7b80fd 100644
--- a/src/cadet/gnunet-service-cadet-new_tunnels.c
+++ b/src/cadet/gnunet-service-cadet-new_tunnels.c
@@ -1256,16 +1256,16 @@ send_kx (struct CadetTunnel *t,
   ct = get_ready_connection (t);
   if (NULL == ct)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Wanted to send KX on tunnel %s, but no connection is ready, 
deferring\n",
-                GCT_2s (t));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Wanted to send KX on tunnel %s, but no connection is ready, 
deferring\n",
+         GCT_2s (t));
     return;
   }
   cc = ct->cc;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending KX on tunnel %s using connection %s\n",
-              GCT_2s (t),
-              GCC_2s (ct->cc));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Sending KX on tunnel %s using connection %s\n",
+       GCT_2s (t),
+       GCC_2s (ct->cc));
 
   // GNUNET_assert (GNUNET_NO == GCT_is_loopback (t));
   env = GNUNET_MQ_msg (msg,
@@ -1395,9 +1395,9 @@ GCT_handle_kx (struct CadetTConnection *ct,
          " known handshake key, exit\n");
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Handling KX message for tunnel %s\n",
-              GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Handling KX message for tunnel %s\n",
+       GCT_2s (t));
 
   ax->RK = keys[0];
   if (GNUNET_YES == am_I_alice)
@@ -1502,10 +1502,10 @@ GCT_add_channel (struct CadetTunnel *t,
                                                       ntohl (ctn.cn),
                                                       ch,
                                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Adding channel %s to tunnel %s\n",
-              GCCH_2s (ch),
-              GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Adding channel %s to tunnel %s\n",
+       GCCH_2s (ch),
+       GCT_2s (t));
   if ( (CADET_TUNNEL_KEY_OK == t->estate) ||
        (CADET_TUNNEL_KEY_REKEY == t->estate) )
     GCCH_tunnel_up (ch);
@@ -1526,9 +1526,9 @@ destroy_tunnel (void *cls)
   struct CadetTunnelQueueEntry *tq;
 
   t->destroy_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Destroying idle tunnel %s\n",
-              GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Destroying idle tunnel %s\n",
+       GCT_2s (t));
   GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (t->channels));
   while (NULL != (ct = t->connection_head))
   {
@@ -1573,10 +1573,10 @@ GCT_remove_channel (struct CadetTunnel *t,
                     struct CadetChannel *ch,
                     struct GNUNET_CADET_ChannelTunnelNumber ctn)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Removing channel %s from tunnel %s\n",
-              GCCH_2s (ch),
-              GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Removing channel %s from tunnel %s\n",
+       GCCH_2s (ch),
+       GCT_2s (t));
   GNUNET_assert (GNUNET_YES ==
                  GNUNET_CONTAINER_multihashmap32_remove (t->channels,
                                                          ntohl (ctn.cn),
@@ -1601,7 +1601,11 @@ GCT_destroy_tunnel_now (struct CadetTunnel *t)
 {
   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);
 }
 
@@ -1643,10 +1647,10 @@ try_send_normal_payload (struct CadetTunnel *t,
   if (NULL == tq)
   {
     /* no messages pending right now */
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Not sending payload of tunnel %s on ready connection %s 
(nothing pending)\n",
-                GCT_2s (t),
-                GCC_2s (ct->cc));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Not sending payload of tunnel %s on ready connection %s (nothing 
pending)\n",
+         GCT_2s (t),
+         GCC_2s (ct->cc));
     return;
   }
   /* ready to send message 'tq' on tunnel 'ct' */
@@ -1657,10 +1661,10 @@ try_send_normal_payload (struct CadetTunnel *t,
   if (NULL != tq->cid)
     *tq->cid = *GCC_get_id (ct->cc);
   ct->is_ready = GNUNET_NO;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending payload of tunnel %s on connection %s\n",
-              GCT_2s (t),
-              GCC_2s (ct->cc));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Sending payload of tunnel %s on connection %s\n",
+       GCT_2s (t),
+       GCC_2s (ct->cc));
   GCC_transmit (ct->cc,
                 tq->env);
   if (NULL != tq->cont)
@@ -1686,19 +1690,19 @@ connection_ready_cb (void *cls,
 
   if (GNUNET_NO == is_ready)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Connection %s no longer ready for tunnel %s\n",
-                GCC_2s (ct->cc),
-                GCT_2s (t));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Connection %s no longer ready for tunnel %s\n",
+         GCC_2s (ct->cc),
+         GCT_2s (t));
     ct->is_ready = GNUNET_NO;
     return;
   }
   ct->is_ready = GNUNET_YES;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Connection %s now ready for tunnel %s in state %s\n",
-              GCC_2s (ct->cc),
-              GCT_2s (t),
-              estate2s (t->estate));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Connection %s now ready for tunnel %s in state %s\n",
+       GCC_2s (ct->cc),
+       GCT_2s (t),
+       estate2s (t->estate));
   switch (t->estate)
   {
   case CADET_TUNNEL_KEY_UNINITIALIZED:
@@ -1781,10 +1785,10 @@ consider_path_cb (void *cls,
     ps = GCC_get_path (ct->cc);
     if (ps == path)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "Ignoring duplicate path %s for tunnel %s.\n",
-                  GCPP_2s (path),
-                  GCT_2s (t));
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Ignoring duplicate path %s for tunnel %s.\n",
+           GCPP_2s (path),
+           GCT_2s (t));
       return GNUNET_YES; /* duplicate */
     }
     min_length = GNUNET_MIN (min_length,
@@ -1803,9 +1807,9 @@ consider_path_cb (void *cls,
   if ( (t->num_connections > DESIRED_CONNECTIONS_PER_TUNNEL) &&
        (min_length * 2 < off) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Ignoring paths of length %u, they are way too long.\n",
-                min_length * 2);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Ignoring paths of length %u, they are way too long.\n",
+         min_length * 2);
     return GNUNET_NO;
   }
   /* If we have enough paths and this one looks no better, ignore it. */
@@ -1813,11 +1817,11 @@ consider_path_cb (void *cls,
        (min_length < GCPP_get_length (path)) &&
        (max_desire > GCPP_get_desirability (path)) )
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Ignoring path (%u/%llu) to %s, got something better 
already.\n",
-                GCPP_get_length (path),
-                (unsigned long long) GCPP_get_desirability (path),
-                GCP_2s (t->destination));
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Ignoring path (%u/%llu) to %s, got something better already.\n",
+         GCPP_get_length (path),
+         (unsigned long long) GCPP_get_desirability (path),
+         GCP_2s (t->destination));
     return GNUNET_YES;
   }
 
@@ -1839,11 +1843,11 @@ consider_path_cb (void *cls,
                                t->connection_tail,
                                ct);
   t->num_connections++;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Found interesting path %s for tunnel %s, created connection 
%s\n",
-              GCPP_2s (path),
-              GCT_2s (t),
-              GCC_2s (ct->cc));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Found interesting path %s for tunnel %s, created connection %s\n",
+       GCPP_2s (path),
+       GCT_2s (t),
+       GCC_2s (ct->cc));
   return GNUNET_YES;
 }
 
@@ -1867,9 +1871,9 @@ maintain_connections_cb (void *cls)
   struct CadetTunnel *t = cls;
 
   t->maintain_connections_task = NULL;
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Performing connection maintenance for tunnel %s.\n",
-              GCT_2s (t));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Performing connection maintenance for tunnel %s.\n",
+       GCT_2s (t));
 
   (void) GCP_iterate_paths (t->destination,
                             &consider_path_cb,

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]