commented out wrong message type
[oweals/gnunet.git] / src / fragmentation / fragmentation.c
index 21bbc538d5c9f476b60723c038a53bad77566aee..f686351004171c94c118610a522277d34f5174f9 100644 (file)
@@ -258,14 +258,18 @@ transmit_next (void *cls)
                                                 fsize);
   else
     delay = GNUNET_TIME_UNIT_ZERO;
-  delay = GNUNET_TIME_relative_max (delay,
-                                   GNUNET_TIME_relative_multiply (fc->msg_delay,
-                                                                  (1ULL << fc->num_rounds)));
+  if (fc->num_rounds < 64)
+    delay = GNUNET_TIME_relative_max (delay,
+                                      GNUNET_TIME_relative_saturating_multiply
+                                      (fc->msg_delay,
+                                       (1ULL << fc->num_rounds)));
+  else
+    delay = GNUNET_TIME_UNIT_FOREVER_REL;
   if (wrap)
   {
     /* full round transmitted wait 2x delay for ACK before going again */
     fc->num_rounds++;
-    delay = GNUNET_TIME_relative_multiply (fc->ack_delay, 2);
+    delay = GNUNET_TIME_relative_saturating_multiply (fc->ack_delay, 2);
     /* never use zero, need some time for ACK always */
     delay = GNUNET_TIME_relative_max (MIN_ACK_DELAY, delay);
     fc->wack = GNUNET_YES;
@@ -369,8 +373,9 @@ GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc)
   fc->proc_busy = GNUNET_NO;
   GNUNET_assert (fc->task == NULL);
   fc->task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining
-                                    (fc->delay_until), &transmit_next, fc);
+    GNUNET_SCHEDULER_add_at (fc->delay_until,
+                             &transmit_next,
+                             fc);
 }
 
 
@@ -428,8 +433,8 @@ GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc,
     if (0 == ack_cnt)
     {
       /* complete loss */
-      fc->msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
-                                                    snd_cnt);
+      fc->msg_delay = GNUNET_TIME_relative_saturating_multiply (fc->msg_delay,
+                                                                snd_cnt);
     }
     else if (snd_cnt > ack_cnt)
     {
@@ -511,8 +516,8 @@ GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc,
   if (NULL != ack_delay)
     *ack_delay = fc->ack_delay;
   if (NULL != msg_delay)
-    *msg_delay = GNUNET_TIME_relative_multiply (fc->msg_delay,
-                                               fc->num_rounds);
+    *msg_delay = GNUNET_TIME_relative_saturating_multiply (fc->msg_delay,
+                                                           fc->num_rounds);
   GNUNET_free (fc);
 }