improve future calculations if messages are skipped in unreliable in-order channels
authorChristian Grothoff <christian@grothoff.org>
Tue, 26 Feb 2019 19:08:17 +0000 (20:08 +0100)
committerChristian Grothoff <christian@grothoff.org>
Tue, 26 Feb 2019 19:08:29 +0000 (20:08 +0100)
src/cadet/gnunet-service-cadet_channel.c

index 905211e00ad2fa928969b49817bcb6da286eca67..10df917ff6458c8be88f16fd6e10462de865ae94 100644 (file)
@@ -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;
     }