}
-/**
- * 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)
- */
-static void
-channel_send_connections_ack (struct MeshChannel *ch,
- unsigned int buffer,
- int fwd)
-{
- struct MeshTunnel3 *t = ch->t;
- struct MeshConnection *c;
- uint32_t allowed;
- uint32_t to_allow;
- uint32_t allow_per_connection;
- unsigned int cs;
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Channel send connection %s ack on %s:%X\n",
- fwd ? "FWD" : "BCK", peer2s (ch->t->peer), ch->gid);
-
- /* Count connections, how many messages are already allowed */
- cs = GMT_count_connections (t);
- for (cs = 0, allowed = 0, c = t->connection_head; NULL != c; c = c->next)
- {
- fc = fwd ? &c->fwd_fc : &c->bck_fc;
- if (GMC_is_pid_bigger (fc->last_pid_recv, fc->last_ack_sent))
- {
- GNUNET_break (0);
- continue;
- }
- allowed += fc->last_ack_sent - fc->last_pid_recv;
- cs++;
- }
-
- /* Make sure there is no overflow */
- if (allowed > buffer)
- {
- GNUNET_break (0);
- return;
- }
-
- /* Authorize connections to send more data */
- to_allow = buffer - allowed;
-
- for (c = t->connection_head; NULL != c && to_allow > 0; c = c->next)
- {
- allow_per_connection = to_allow/cs;
- to_allow -= allow_per_connection;
- cs--;
- fc = fwd ? &c->fwd_fc : &c->bck_fc;
- if (fc->last_ack_sent - fc->last_pid_recv > 64 / 3)
- {
- continue;
- }
- GMC_send_ack (c, allow_per_connection, fwd);
- }
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Channel send connection %s ack on %s:%X\n",
- fwd ? "FWD" : "BCK", GMT_2s (ch->t), ch->gid);
- GNUNET_break (to_allow == 0);
-}
-
-
/**
* Destroy a reliable message after it has been acknowledged, either by
* direct mid ACK or bitfield. Updates the appropriate data structures and