From 9787c209921963ea60f1fdf5c8dc04a16cc344b3 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 26 Feb 2019 20:08:17 +0100 Subject: [PATCH] improve future calculations if messages are skipped in unreliable in-order channels --- src/cadet/gnunet-service-cadet_channel.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index 905211e00..10df917ff 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c @@ -1333,6 +1333,18 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch, env); ch->mid_recv.mid = htonl (1 + ntohl (ch->mid_recv.mid)); ch->mid_futures >>= 1; + if ( (GNUNET_YES == ch->out_of_order) && + (GNUNET_NO == ch->reliable) ) + { + /* possibly shift by more if we skipped messages */ + uint64_t delta = htonl (msg->mid.mid) - 1 - ntohl (ch->mid_recv.mid); + + if (delta > 63) + ch->mid_futures = 0; + else + ch->mid_futures >>= delta; + ch->mid_recv.mid = htonl (1 + ntohl (msg->mid.mid)); + } send_channel_data_ack (ch); return; } -- 2.25.1