From 5198a0e5b21f8bd0d13f2817602be401f96b726d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 31 Jan 2017 11:44:08 +0100 Subject: [PATCH] do not recompute off if we can just pass it in --- src/cadet/gnunet-service-cadet-new_connection.c | 12 +++++++----- src/cadet/gnunet-service-cadet-new_connection.h | 2 ++ src/cadet/gnunet-service-cadet-new_paths.c | 3 +++ src/cadet/gnunet-service-cadet-new_tunnels.c | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cadet/gnunet-service-cadet-new_connection.c b/src/cadet/gnunet-service-cadet-new_connection.c index 8536b638d..0ccfe8b45 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.c +++ b/src/cadet/gnunet-service-cadet-new_connection.c @@ -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, diff --git a/src/cadet/gnunet-service-cadet-new_connection.h b/src/cadet/gnunet-service-cadet-new_connection.h index 61d9d5d78..73388be7f 100644 --- a/src/cadet/gnunet-service-cadet-new_connection.h +++ b/src/cadet/gnunet-service-cadet-new_connection.h @@ -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, diff --git a/src/cadet/gnunet-service-cadet-new_paths.c b/src/cadet/gnunet-service-cadet-new_paths.c index 4f2c0036f..28c43d1cf 100644 --- a/src/cadet/gnunet-service-cadet-new_paths.c +++ b/src/cadet/gnunet-service-cadet-new_paths.c @@ -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;offt = 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, -- 2.25.1