- add underlay api implementation
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_channel.c
index f06844584bfa9010ddf3d827aced65d40312285e..2e52a2ea5da6898985240fe92b830533c0e543ef 100644 (file)
@@ -735,7 +735,9 @@ ch_message_sent (void *cls,
       rel = copy->rel;
       if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task)
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry %u\n");
+        LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in %s\n",
+             GNUNET_STRINGS_relative_time_to_string (rel->expected_delay,
+                                                     GNUNET_YES));
         if (0 != rel->expected_delay.rel_value_us)
         {
           LOG (GNUNET_ERROR_TYPE_DEBUG, "!! delay != 0\n");
@@ -745,7 +747,7 @@ ch_message_sent (void *cls,
         }
         else
         {
-          LOG (GNUNET_ERROR_TYPE_DEBUG, "!! delay 0\n");
+          LOG (GNUNET_ERROR_TYPE_DEBUG, "!! delay reset\n");
           rel->retry_timer = MESH_RETRANSMIT_TIME;
         }
         LOG (GNUNET_ERROR_TYPE_DEBUG, "!! using delay %s\n",
@@ -927,6 +929,7 @@ channel_rel_free_all (struct MeshChannelReliability *rel)
     next = copy->next;
     GNUNET_CONTAINER_DLL_remove (rel->head_recv, rel->tail_recv, copy);
     LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE BATCH RECV %p\n", copy);
+    GNUNET_break (NULL == copy->q);
     GNUNET_free (copy);
   }
   for (copy = rel->head_sent; NULL != copy; copy = next)
@@ -934,6 +937,19 @@ channel_rel_free_all (struct MeshChannelReliability *rel)
     next = copy->next;
     GNUNET_CONTAINER_DLL_remove (rel->head_sent, rel->tail_sent, copy);
     LOG (GNUNET_ERROR_TYPE_DEBUG, " COPYFREE BATCH %p\n", copy);
+    if (NULL != copy->q)
+    {
+      if (NULL != copy->q->q)
+      {
+        GMT_cancel (copy->q->q);
+        /* ch_message_sent will free copy->q */
+      }
+      else
+      {
+        GNUNET_free (copy->q);
+        GNUNET_break (0);
+      }
+    }
     GNUNET_free (copy);
   }
   if (NULL != rel->uniq && NULL != rel->uniq->q)
@@ -1099,8 +1115,8 @@ channel_confirm (struct MeshChannel *ch, int fwd)
   enum MeshChannelState oldstate;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-              "  channel confirm %s %s:%X\n",
-              GM_f2s (fwd), GMT_2s (ch->t), ch->gid);
+              "  channel confirm %s %s\n",
+              GM_f2s (fwd), GMCH_2s (ch));
   oldstate = ch->state;
   ch->state = MESH_CHANNEL_READY;
 
@@ -1121,7 +1137,7 @@ channel_confirm (struct MeshChannel *ch, int fwd)
   else if (NULL != rel->uniq)
   {
     GMT_cancel (rel->uniq->q);
-    /* ch_sent_message will free and NULL uniq */
+    /* ch_message_sent will free and NULL uniq */
   }
   else
   {
@@ -2259,6 +2275,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
                                           NULL != existing_copy,
                                           &ch_message_sent, q);
         /* q itself is stored in copy */
+        GNUNET_assert (NULL != q->q || GNUNET_NO != ch->destroy);
       }
       else
       {