From 23d6fc8a35b168370bca63cbc918f1ac817dd8f9 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Tue, 17 Jun 2014 12:13:31 +0000 Subject: [PATCH] - limit queued messages on tunnel level when tunnel is not ready --- src/cadet/gnunet-service-cadet_tunnel.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c index 347152f42..adc3eb342 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.c +++ b/src/cadet/gnunet-service-cadet_tunnel.c @@ -896,6 +896,18 @@ tun_message_sent (void *cls, } +static unsigned int +count_queued_data (const struct CadetTunnel *t) +{ + struct CadetTunnelDelayed *iter; + unsigned int count; + + for (count = 0, iter = t->tq_head; iter != NULL; iter = iter->next) + count++; + + return count; +} + /** * Delete a queued message: either was sent or the channel was destroyed * before the tunnel's key exchange had a chance to finish. @@ -2651,6 +2663,14 @@ GCT_get_connections_buffer (struct CadetTunnel *t) struct CadetTConnection *iter; unsigned int buffer; + if (GNUNET_NO == is_ready (t)) + { + if (count_queued_data (t) > 3) + return 0; + else + return 1; + } + buffer = 0; for (iter = t->connection_head; NULL != iter; iter = iter->next) { -- 2.25.1