From 8f6c85fba2386a4e6673f07e32dbfefcfcffdd1c Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 11 Oct 2013 15:37:21 +0000 Subject: [PATCH] - mesh builds again --- src/mesh/Makefile.am | 4 ++-- src/mesh/gnunet-service-mesh_connection.c | 26 +++++++++++++++++---- src/mesh/gnunet-service-mesh_connection.h | 13 +++++++++++ src/mesh/gnunet-service-mesh_tunnel.c | 28 ++++++++++++++--------- src/mesh/gnunet-service-mesh_tunnel.h | 11 +++++++++ 5 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index c8c09545f..df1c74c87 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am @@ -23,8 +23,8 @@ AM_CLFAGS = -g EXP_LIB = \ libgnunetmeshenc.la -#EXP_LIBEXEC = \ -# gnunet-service-mesh-enc +EXP_LIBEXEC = \ + gnunet-service-mesh-enc libexec_PROGRAMS = \ gnunet-service-mesh $(EXP_LIBEXEC) diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 94813adf2..fbc021154 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -516,7 +516,8 @@ connection_send_ack (struct MeshConnection *c, unsigned int buffer, int fwd) fwd ? "FWD" : "BCK", GNUNET_h2s (&c->id)); /* Check if we need to transmit the ACK */ - if (prev_fc->last_ack_sent - prev_fc->last_pid_recv > 3) + delta = prev_fc->last_ack_sent - prev_fc->last_pid_recv; + if (3 < delta && buffer < delta) { LOG (GNUNET_ERROR_TYPE_DEBUG, "Not sending ACK, buffer > 3\n"); LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -526,8 +527,7 @@ connection_send_ack (struct MeshConnection *c, unsigned int buffer, int fwd) } /* Ok, ACK might be necessary, what PID to ACK? */ - delta = next_fc->queue_max - next_fc->queue_n; - ack = prev_fc->last_pid_recv + delta; + ack = prev_fc->last_pid_recv + buffer; LOG (GNUNET_ERROR_TYPE_DEBUG, " ACK %u\n", ack); LOG (GNUNET_ERROR_TYPE_DEBUG, " last pid %u, last ack %u, qmax %u, q %u\n", @@ -1695,7 +1695,7 @@ GMC_send_ack (struct MeshConnection *c, struct MeshChannel *ch, int fwd) { LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on all connections\n"); GNUNET_assert (NULL != ch); - channel_send_connections_ack (ch, buffer, fwd); + GMT_send_acks (GMCH_get_tunnel (ch), buffer, fwd); } else { @@ -1751,6 +1751,7 @@ GMC_init (const struct GNUNET_CONFIGURATION_Handle *c) void GMC_shutdown (void) { + GNUNET_CONTAINER_multihashmap_destroy (connections); } @@ -1933,6 +1934,23 @@ GMC_get_qn (struct MeshConnection *c, int fwd) } +/** + * Allow the connection to advertise a buffer of the given size. + * + * The connection will send an @c fwd ACK message (so: in direction !fwd) + * allowing up to last_pid_recv + buffer. + * + * @param c Connection. + * @param buffer How many more messages the connection can accept. + * @param fwd Is this about FWD traffic? (The ack will go dest->root). + */ +void +GMC_allow (struct MeshConnection *c, unsigned int buffer, int fwd) +{ + connection_send_ack (c, buffer, fwd); +} + + /** * Send a notification that a connection is broken. * diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index a617054ff..bdfaaf988 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h @@ -327,6 +327,19 @@ GMC_get_allowed (struct MeshConnection *c, int fwd); unsigned int GMC_get_qn (struct MeshConnection *c, int fwd); +/** + * Allow the connection to advertise a buffer of the given size. + * + * The connection will send an @c fwd ACK message (so: in direction !fwd) + * allowing up to last_pid_recv + buffer. + * + * @param c Connection. + * @param buffer How many more messages the connection can accept. + * @param fwd Is this about FWD traffic? (The ack will go dest->root). + */ +void +GMC_allow (struct MeshConnection *c, unsigned int buffer, int fwd); + /** * Send FWD keepalive packets for a connection. * diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index 105317501..01f581c27 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1095,10 +1095,8 @@ GMT_get_next_chid (struct MeshTunnel3 *t) * @param ch Channel which has some free buffer space. * @param fwd Is this in for FWD traffic? (ACK goes dest->root) */ -static void -GMT_send_acks (struct MeshTunnel3 *t, - unsigned int buffer, - int fwd) +void +GMT_send_acks (struct MeshTunnel3 *t, unsigned int buffer, int fwd) { struct MeshTConnection *iter; uint32_t allowed; @@ -1108,7 +1106,19 @@ GMT_send_acks (struct MeshTunnel3 *t, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Tunnel send acks on %s:%X\n", - fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid); + fwd ? "FWD" : "BCK", GMT_2s (t)); + + if (NULL == t) + { + GNUNET_break (0); + return; + } + if (NULL == t->channel_head || + GNUNET_NO == GMCH_is_origin (t->channel_head->ch, fwd)) + { + GNUNET_break (0); + return; + } /* Count connections, how many messages are already allowed */ cs = GMT_count_connections (t); @@ -1125,7 +1135,7 @@ GMT_send_acks (struct MeshTunnel3 *t, } /* Authorize connections to send more data */ - to_allow = buffer - allowed; + to_allow = buffer; /* - allowed; */ for (iter = t->connection_head; NULL != iter && to_allow > 0; iter = iter->next) { @@ -1136,13 +1146,9 @@ GMT_send_acks (struct MeshTunnel3 *t, { continue; } - GMC_send_ack (iter->c, NULL, fwd); - connection_send_ack (iter, allow_per_connection, fwd); + GMC_allow (iter->c, buffer, fwd); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Channel send connection %s ack on %s:%X\n", - fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid); GNUNET_break (to_allow == 0); } diff --git a/src/mesh/gnunet-service-mesh_tunnel.h b/src/mesh/gnunet-service-mesh_tunnel.h index c5c13b28b..e15d07988 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.h +++ b/src/mesh/gnunet-service-mesh_tunnel.h @@ -309,6 +309,17 @@ GMT_get_destination (struct MeshTunnel3 *t); MESH_ChannelNumber GMT_get_next_chid (struct MeshTunnel3 *t); +/** + * Send ACK on one or more connections due to buffer space to the client. + * + * Iterates all connections of the tunnel and sends ACKs appropriately. + * + * @param ch Channel which has some free buffer space. + * @param fwd Is this in for FWD traffic? (ACK goes dest->root) + */ +void +GMT_send_acks (struct MeshTunnel3 *t, unsigned int buffer, int fwd); + /** * Sends an already built message on a tunnel, encrypting it and * choosing the best connection. -- 2.25.1