do not recompute off if we can just pass it in
authorChristian Grothoff <christian@grothoff.org>
Tue, 31 Jan 2017 10:44:08 +0000 (11:44 +0100)
committerChristian Grothoff <christian@grothoff.org>
Tue, 31 Jan 2017 10:44:08 +0000 (11:44 +0100)
src/cadet/gnunet-service-cadet-new_connection.c
src/cadet/gnunet-service-cadet-new_connection.h
src/cadet/gnunet-service-cadet-new_paths.c
src/cadet/gnunet-service-cadet-new_tunnels.c

index 8536b638da8821bb4c98fee7876fa4a4800ab517..0ccfe8b458c2a8c2dca4b2728ac2cbf918f59b17 100644 (file)
@@ -778,6 +778,7 @@ manage_first_hop_mq (void *cls,
  *
  * @param destination where to go
  * @param path which path to take (may not be the full path)
+ * @param off offset of @a destination on @a path
  * @param options options for the connection
  * @param ct which tunnel uses this connection
  * @param init_state initial state for the connection
@@ -788,6 +789,7 @@ manage_first_hop_mq (void *cls,
 static struct CadetConnection *
 connection_create (struct CadetPeer *destination,
                    struct CadetPeerPath *path,
+                   unsigned int off,
                    enum GNUNET_CADET_ChannelOption options,
                    struct CadetTConnection *ct,
                    const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
@@ -797,11 +799,7 @@ connection_create (struct CadetPeer *destination,
 {
   struct CadetConnection *cc;
   struct CadetPeer *first_hop;
-  unsigned int off;
 
-  off = GCPP_find_peer (path,
-                        destination);
-  GNUNET_assert (UINT_MAX > off);
   cc = GNUNET_new (struct CadetConnection);
   cc->options = options;
   cc->state = init_state;
@@ -854,7 +852,7 @@ connection_create (struct CadetPeer *destination,
 struct CadetConnection *
 GCC_create_inbound (struct CadetPeer *destination,
                     struct CadetPeerPath *path,
-                   enum GNUNET_CADET_ChannelOption options,
+                    enum GNUNET_CADET_ChannelOption options,
                     struct CadetTConnection *ct,
                     const struct GNUNET_CADET_ConnectionTunnelIdentifier *cid,
                     GCC_ReadyCallback ready_cb,
@@ -910,6 +908,7 @@ GCC_create_inbound (struct CadetPeer *destination,
 
   return connection_create (destination,
                             path,
+                            off,
                             options,
                             ct,
                             cid,
@@ -925,6 +924,7 @@ GCC_create_inbound (struct CadetPeer *destination,
  *
  * @param destination where to go
  * @param path which path to take (may not be the full path)
+ * @param off offset of @a destination on @a path
  * @param options options for the connection
  * @param ct tunnel that uses the connection
  * @param ready_cb function to call when ready to transmit
@@ -934,6 +934,7 @@ GCC_create_inbound (struct CadetPeer *destination,
 struct CadetConnection *
 GCC_create (struct CadetPeer *destination,
             struct CadetPeerPath *path,
+            unsigned int off,
             enum GNUNET_CADET_ChannelOption options,
             struct CadetTConnection *ct,
             GCC_ReadyCallback ready_cb,
@@ -946,6 +947,7 @@ GCC_create (struct CadetPeer *destination,
                               sizeof (cid));
   return connection_create (destination,
                             path,
+                            off,
                             options,
                             ct,
                             &cid,
index 61d9d5d78631544b132667426490acc1805ac2d1..73388be7fce5d422355249e529065d42b8bfef24 100644 (file)
@@ -78,6 +78,7 @@ GCC_destroy_without_tunnel (struct CadetConnection *cc);
  *
  * @param destination where to go
  * @param path which path to take (may not be the full path)
+ * @param off offset of @a destination on @a path
  * @param options options for the connection
  * @param ct which tunnel uses this connection
  * @param ready_cb function to call when ready to transmit
@@ -87,6 +88,7 @@ GCC_destroy_without_tunnel (struct CadetConnection *cc);
 struct CadetConnection *
 GCC_create (struct CadetPeer *destination,
             struct CadetPeerPath *path,
+            unsigned int off,
             enum GNUNET_CADET_ChannelOption options,
             struct CadetTConnection *ct,
             GCC_ReadyCallback ready_cb,
index 4f2c0036fea17e2be19957b5403dba59a070bcd9..28c43d1cf6cc7d0fe5befa1aaf98d2f1598fa2c5 100644 (file)
@@ -478,6 +478,9 @@ GCPP_try_path_from_dht (const struct GNUNET_PeerIdentity *get_path,
 
   /* precompute 'cpath' so we can avoid doing the lookups lots of times */
   skip = 0;
+  memset (cpath,
+          0,
+          sizeof (cpath)); /* Just to trigger harder errors later. */
   total_len = get_path_length + put_path_length;
   for (unsigned int off=0;off<total_len;off++)
   {
index a9f8dfffc3239807e65c7cb3ff07a57a7bcd83ac..ee1502cabe5d9808e24f0f76b94368fccd747b1b 100644 (file)
@@ -2467,6 +2467,7 @@ consider_path_cb (void *cls,
   ct->t = t;
   ct->cc = GCC_create (t->destination,
                        path,
+                       off,
                        GNUNET_CADET_OPTION_DEFAULT, /* FIXME: set based on what channels want/need! */
                        ct,
                        &connection_ready_cb,