- mesh builds again
authorBart Polot <bart@net.in.tum.de>
Fri, 11 Oct 2013 15:37:21 +0000 (15:37 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 11 Oct 2013 15:37:21 +0000 (15:37 +0000)
src/mesh/Makefile.am
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_connection.h
src/mesh/gnunet-service-mesh_tunnel.c
src/mesh/gnunet-service-mesh_tunnel.h

index c8c09545fcd64c9614482ba4c407ca6da5169b79..df1c74c8784774b20a2a7fc8a9877b92bc7cbc8b 100644 (file)
@@ -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)
index 94813adf24efe74a88d0261ae375cee503cf54f5..fbc02115421fd9cf03b2b622f3c773388d292175 100644 (file)
@@ -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.
  *
index a617054ffa3fbfebb27bd8fb7283c6d739f4d441..bdfaaf98830a7bceb149a1ee2cdb8f54f208ac4f 100644 (file)
@@ -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.
  *
index 105317501f0a5fa3519c449d941c42e69392bbe5..01f581c27fb2ecccd0410f0226d0ba4113126bdc 100644 (file)
@@ -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);
 }
 
index c5c13b28b78c320a0f0307ff15e3ba65c093fae8..e15d07988701f1e83594b2fa8b6cf87f68da056e 100644 (file)
@@ -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.