- doc
authorBart Polot <bart@net.in.tum.de>
Fri, 15 Nov 2013 17:00:41 +0000 (17:00 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 15 Nov 2013 17:00:41 +0000 (17:00 +0000)
- use tunnel queues on channel retransmit

src/mesh/gnunet-service-mesh_channel.c
src/mesh/gnunet-service-mesh_channel.h
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_connection.h
src/mesh/gnunet-service-mesh_tunnel.c
src/mesh/gnunet-service-mesh_tunnel.h

index d3de56f92a5d07f5d42c924376604790a4ba65a5..b369461309ec771decd9c27967f70340e8906713 100644 (file)
@@ -636,44 +636,14 @@ channel_retransmit_message (void *cls,
     return;
   }
 
-  /* Search the message to be retransmitted in the outgoing queue.
-   * Check only the queue for the connection that is going to be used,
-   * if the message is stuck in some other connection's queue we shouldn't
-   * act upon it:
-   * - cancelling it and sending the new one doesn't guarantee it's delivery,
-   *   the old connection could be temporary stalled or the queue happened to
-   *   be long at time of insertion.
-   * - not sending the new one could cause terrible delays the old connection
-   *   is stalled.
-   */
-//   FIXME access to queue elements is limited
   payload = (struct GNUNET_MESH_Data *) &copy[1];
   fwd = (rel == ch->root_rel);
-//   c = GMT_get_connection (ch->t, fwd);
-//   hop = connection_get_hop (c, fwd);
-//   for (q = hop->queue_head; NULL != q; q = q->next)
-//   {
-//     if (ntohs (payload->header.type) == q->type && ch == q->ch)
-//     {
-//       struct GNUNET_MESH_Data *queued_data = q->cls;
-// 
-//       if (queued_data->mid == payload->mid)
-//         break;
-//     }
-//   }
 
   /* Message not found in the queue that we are going to use. */
-//   if (NULL == q)
-//   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
-
-    GMCH_send_prebuilt_message (&payload->header, ch, fwd);
-    GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
-//   }
-//   else
-//   {
-//     LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! ALREADY IN QUEUE %u\n", copy->mid);
-//   }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! RETRANSMIT %u\n", copy->mid);
+
+  GMCH_send_prebuilt_message (&payload->header, ch, fwd, GNUNET_YES);
+  GNUNET_STATISTICS_update (stats, "# data retransmitted", 1, GNUNET_NO);
 
   copy->timestamp = GNUNET_TIME_absolute_get();
   rel->retry_timer = GNUNET_TIME_STD_BACKOFF (rel->retry_timer);
@@ -742,7 +712,7 @@ channel_send_ack (struct MeshChannel *ch, int fwd)
               fwd ? "FWD" : "BCK", GMCH_2s (ch));
 
   msg.chid = htonl (ch->gid);
-  GMCH_send_prebuilt_message (&msg.header, ch, !fwd);
+  GMCH_send_prebuilt_message (&msg.header, ch, !fwd, GNUNET_NO);
 }
 
 
@@ -763,7 +733,7 @@ channel_send_nack (struct MeshChannel *ch)
        GMCH_2s (ch));
 
   msg.chid = htonl (ch->gid);
-  GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO);
+  GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, GNUNET_NO);
 }
 
 
@@ -1183,12 +1153,12 @@ GMCH_send_destroy (struct MeshChannel *ch)
   if (NULL != ch->root)
     GML_send_channel_destroy (ch->root, ch->lid_root);
   else if (0 == ch->lid_root)
-    GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO);
+    GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_NO, GNUNET_NO);
 
   if (NULL != ch->dest)
     GML_send_channel_destroy (ch->dest, ch->lid_dest);
   else if (0 == ch->lid_dest)
-    GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES);
+    GMCH_send_prebuilt_message (&msg.header, ch, GNUNET_YES, GNUNET_NO);
 }
 
 
@@ -1252,7 +1222,7 @@ GMCH_send_data_ack (struct MeshChannel *ch, int fwd)
        "!!! ACK for %u, futures %llX\n",
        ack, msg.futures);
 
-  GMCH_send_prebuilt_message (&msg.header, ch, !fwd);
+  GMCH_send_prebuilt_message (&msg.header, ch, !fwd, GNUNET_NO);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n");
 }
 
@@ -1433,7 +1403,7 @@ GMCH_handle_local_data (struct MeshChannel *ch,
   payload->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_DATA);
   payload->chid = htonl (ch->gid);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "  sending on channel...\n");
-  GMCH_send_prebuilt_message (&payload->header, ch, fwd);
+  GMCH_send_prebuilt_message (&payload->header, ch, fwd, GNUNET_NO);
 
   if (is_loopback (ch))
   {
@@ -1921,10 +1891,12 @@ GMCH_handle_destroy (struct MeshChannel *ch,
  * @param message Message to send. Function makes a copy of it.
  * @param ch Channel on which this message is transmitted.
  * @param fwd Is this a fwd message?
+ * @param retransmission Is this a retransmission? (Don't save a copy)
  */
 void
 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
-                            struct MeshChannel *ch, int fwd)
+                            struct MeshChannel *ch, int fwd,
+                            int retransmission)
 {
   LOG (GNUNET_ERROR_TYPE_DEBUG, "GMCH Send %s %s on channel %s\n",
        fwd ? "FWD" : "BCK", GNUNET_MESH_DEBUG_M2S (ntohs (message->type)), 
@@ -1936,7 +1908,7 @@ GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
     return;
   }
 
-  if (GNUNET_YES == ch->reliable
+  if (GNUNET_YES == ch->reliable && GNUNET_NO == retransmission
       && ntohs (message->type) == GNUNET_MESSAGE_TYPE_MESH_DATA)
   {
     struct MeshReliableMessage *copy;
index 461aef5626df793f686e6686ccf4a631010c7d58..66b203192d3cc8f9c464cfd258cf6e47c2134fa0 100644 (file)
@@ -314,15 +314,17 @@ GMCH_handle_destroy (struct MeshChannel *ch,
  * @param message Message to send. Function makes a copy of it.
  * @param ch Channel on which this message is transmitted.
  * @param fwd Is this a fwd message?
+ * @param retransmission Is this a retransmission? (Don't save a copy)
  */
 void
 GMCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
-                            struct MeshChannel *ch, int fwd);
+                            struct MeshChannel *ch, int fwd,
+                            int retransmission);
 
 /**
  * Get the static string for identification of the channel.
  *
- * @param ch Channel.
+ * @param ch Channel.i
  *
  * @return Static string with the channel IDs.
  */
index 774e8bcc3ed3d0444a6d27c546a93e412e5fbd23..a7af5eb60d362d3656807f6f53f79848c348eeee 100644 (file)
@@ -2547,10 +2547,6 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
  * is called. Once the continuation is called, the message is no longer in the
  * queue.
  *
- * If the send function was given no continuation, GMC_cancel should
- * NOT be called, since it's not possible to determine if the message has
- * already been sent.
- *
  * @param q Handle to the queue.
  */
 void
index 6faf594affbd810b234cbeedc59a1c9f80187c42..00b5e082ba1f1693e1e8d5b32a0dc45c3bd73649 100644 (file)
@@ -434,10 +434,6 @@ GMC_is_sendable (struct MeshConnection *c, int fwd);
  * is called. Once the continuation is called, the message is no longer in the
  * queue.
  *
- * If the send function was given no continuation, GMC_cancel should
- * NOT be called, since it's not possible to determine if the message has
- * already been sent.
- *
  * @param q Handle to the queue.
  */
 void
index 26fe909e7e04d138b7fc470d5b96dca95c9a6b4f..e30c8cd978dba1d9a2b55fe0fbcfc4ccdff2e7d3 100644 (file)
@@ -578,7 +578,8 @@ send_queued_data (struct MeshTunnel3 *t)
     room--;
     GNUNET_CONTAINER_DLL_remove (t->tq_head, t->tq_tail, tq);
     GMCH_send_prebuilt_message ((struct GNUNET_MessageHeader *) &tq[1],
-                                tq->ch, GMCH_is_origin (tq->ch, GNUNET_YES));
+                                tq->ch, GMCH_is_origin (tq->ch, GNUNET_YES),
+                                GNUNET_NO);
 
     GNUNET_free (tq);
   }
@@ -2000,6 +2001,23 @@ message_sent (void *cls,
   GNUNET_free (qt);
 }
 
+
+/**
+ * Cancel a previously sent message while it's in the queue.
+ *
+ * ONLY can be called before the continuation given to the send function
+ * is called. Once the continuation is called, the message is no longer in the
+ * queue.
+ *
+ * @param q Handle to the queue.
+ */
+void
+GMT_cancel (struct MeshTunnel3Queue *q)
+{
+  GMC_cancel (q->q);
+  /* message_sent() will be called and free q */
+}
+
 /**
  * Sends an already built message on a tunnel, encrypting it and
  * choosing the best connection.
index 89a86ee6c1c4436b8c625c5791a65a7afca4c4de..d4be562a2556c99e3990895b248b2595e6d193b9 100644 (file)
@@ -351,6 +351,18 @@ GMT_unchoke_channels (struct MeshTunnel3 *t);
 void
 GMT_send_connection_acks (struct MeshTunnel3 *t);
 
+/**
+ * Cancel a previously sent message while it's in the queue.
+ *
+ * ONLY can be called before the continuation given to the send function
+ * is called. Once the continuation is called, the message is no longer in the
+ * queue.
+ *
+ * @param q Handle to the queue.
+ */
+void
+GMT_cancel (struct MeshTunnel3Queue *q);
+
 /**
  * Sends an already built message on a tunnel, encrypting it and
  * choosing the best connection.