gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r33180 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r33180 - gnunet/src/mesh
Date: Wed, 7 May 2014 12:42:51 +0200

Author: bartpolot
Date: 2014-05-07 12:42:51 +0200 (Wed, 07 May 2014)
New Revision: 33180

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/gnunet-service-mesh_peer.c
   gnunet/src/mesh/gnunet-service-mesh_peer.h
Log:
- Eliminate next_pid

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-05-07 10:42:47 UTC 
(rev 33179)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-05-07 10:42:51 UTC 
(rev 33180)
@@ -71,11 +71,6 @@
   unsigned int queue_max;
 
   /**
-   * Next ID to use.
-   */
-  uint32_t next_pid;
-
-  /**
    * ID of the last packet sent towards the peer.
    */
   uint32_t last_pid_sent;
@@ -239,11 +234,6 @@
   int forced;
 
   /**
-   * Packet ID of the message, if relevant.
-   */
-  uint32_t pid;
-
-  /**
    * Continuation to call once sent.
    */
   GMC_sent cont;
@@ -400,7 +390,6 @@
 static void
 fc_init (struct MeshFlowControl *fc)
 {
-  fc->next_pid = 0;
   fc->last_pid_sent = (uint32_t) -1; /* Next (expected) = 0 */
   fc->last_pid_recv = (uint32_t) -1;
   fc->last_ack_sent = (uint32_t) 0;
@@ -557,7 +546,7 @@
 
 
 /**
- * Callback called when a queued message is sent.
+ * Callback called when a connection queued message is sent.
  *
  * Calculates the average time and connection packet tracking.
  *
@@ -565,32 +554,30 @@
  * @param c Connection this message was on.
  * @param sent Was it really sent? (Could have been canceled)
  * @param type Type of message sent.
+ * @param pid Packet ID, or 0 if not applicable (create, destroy, etc).
  * @param fwd Was this a FWD going message?
  * @param size Size of the message.
  * @param wait Time spent waiting for core (only the time for THIS message)
  */
 static void
-message_sent (void *cls,
-              struct MeshConnection *c, int sent,
-              uint16_t type, int fwd, size_t size,
-              struct GNUNET_TIME_Relative wait)
+conn_message_sent (void *cls,
+                   struct MeshConnection *c, int sent,
+                   uint16_t type, uint32_t pid, int fwd, size_t size,
+                   struct GNUNET_TIME_Relative wait)
 {
   struct MeshConnectionPerformance *p;
   struct MeshFlowControl *fc;
   struct MeshConnectionQueue *q = cls;
   double usecsperbyte;
   int forced;
-  uint32_t pid;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "connection message_sent\n");
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
-  pid = 0;
   LOG (GNUNET_ERROR_TYPE_DEBUG, " %ssent %s %s\n",
        sent ? "" : "not ", GM_f2s (fwd), GM_m2s (type));
   if (NULL != q)
   {
-    pid = q->pid;
     forced = q->forced;
     if (NULL != q->cont)
     {
@@ -639,7 +626,7 @@
       if (GNUNET_YES == sent)
       {
         GNUNET_assert (NULL != q);
-        fc->last_pid_sent = pid;
+        fc->last_pid_sent = pid; // FIXME
         GMC_send_ack (c, fwd, GNUNET_NO);
         connection_reset_timeout (c, fwd);
       }
@@ -821,7 +808,7 @@
                  GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
                  GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK, 0,
                  sizeof (struct GNUNET_MESH_ConnectionACK),
-                 connection, fwd, &message_sent, NULL);
+                 connection, fwd, &conn_message_sent, NULL);
   connection->pending_messages++;
   if (MESH_TUNNEL3_NEW == GMT_get_cstate (t))
     GMT_change_cstate (t, MESH_TUNNEL3_WAITING);
@@ -2841,8 +2828,8 @@
   }
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       " last ack recv: %u, last pid sent: %u, next pid %u\n",
-       fc->last_ack_recv, fc->last_pid_sent, fc->next_pid);
+       " last ack recv: %u, last pid sent: %u\n",
+       fc->last_ack_recv, fc->last_pid_sent);
   if (GM_is_pid_bigger (fc->last_ack_recv, fc->last_pid_sent))
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, " sendable\n");
@@ -2891,7 +2878,6 @@
 {
   struct MeshFlowControl *fc;
   struct MeshConnectionQueue *q;
-  uint32_t pid;
   void *data;
   size_t size;
   uint16_t type;
@@ -2906,7 +2892,6 @@
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   droppable = GNUNET_NO == force;
-  pid = 0;
   switch (type)
   {
     struct GNUNET_MESH_Encrypted *emsg;
@@ -2928,10 +2913,8 @@
       }
       emsg->cid = c->id;
       emsg->ttl = htonl (ttl - 1);
-      pid = fc->next_pid++;
-      emsg->pid = htonl (pid);
+      emsg->pid = htonl (0);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "  Q_N+ %p %u\n", fc, fc->queue_n);
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", pid);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent);
       LOG (GNUNET_ERROR_TYPE_DEBUG, "     ack recv %u\n", fc->last_ack_recv);
       if (GNUNET_YES == droppable)
@@ -3001,7 +2984,6 @@
     if (GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED == type)
     {
       fc->queue_n--;
-      fc->next_pid--;
     }
     GNUNET_free (data);
     return NULL; /* Drop this message */
@@ -3012,9 +2994,8 @@
 
   q = GNUNET_new (struct MeshConnectionQueue);
   q->forced = !droppable;
-  q->pid = pid;
   q->q = GMP_queue_add (get_hop (c, fwd), data, type, payload_type, payload_id,
-                        size, c, fwd, &message_sent, q);
+                        size, c, fwd, &conn_message_sent, q);
   if (NULL == q->q)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING dropping msg on %s\n", GMC_2s (c));
@@ -3043,7 +3024,7 @@
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!  GMC cancel message\n");
 
   /* queue destroy calls message_sent, which calls q->cont and frees q */
-  GMP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO);
+  GMP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0);
 }
 
 
@@ -3073,7 +3054,7 @@
     GMP_queue_add (get_next_hop (connection), NULL,
                    GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE,
                    GNUNET_MESSAGE_TYPE_MESH_CONNECTION_CREATE, 0,
-                   size, connection, GNUNET_YES, &message_sent, NULL);
+                   size, connection, GNUNET_YES, &conn_message_sent, NULL);
 
   state = GMT_get_cstate (connection->t);
   if (MESH_TUNNEL3_SEARCHING == state || MESH_TUNNEL3_NEW == state)

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.c  2014-05-07 10:42:47 UTC (rev 
33179)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.c  2014-05-07 10:42:51 UTC (rev 
33180)
@@ -905,7 +905,9 @@
   struct MeshPeerQueue *queue;
   const struct GNUNET_PeerIdentity *dst_id;
   size_t data_size;
+  uint32_t pid;
 
+  pid = 0;
   peer->core_transmit = NULL;
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Queue send towards %s (max %u)\n",
        GMP_2s (peer), size);
@@ -926,7 +928,8 @@
   c = queue->c;
 
   dst_id = GNUNET_PEER_resolve2 (peer->id);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  on connection %s\n", GMC_2s (c));
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "  on connection %s %s\n",
+       GMC_2s (c), GM_f2s(queue->fwd));
   /* Check if buffer size is enough for the message */
   if (queue->size > size)
   {
@@ -947,9 +950,12 @@
   /* Fill buf */
   switch (queue->type)
   {
+    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
+      pid = GMC_get_pid (queue->c, queue->fwd);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "  payload ID %u\n", pid);
+      /* fall-through */
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY:
     case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
-    case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
     case GNUNET_MESSAGE_TYPE_MESH_KX:
     case GNUNET_MESSAGE_TYPE_MESH_ACK:
     case GNUNET_MESSAGE_TYPE_MESH_POLL:
@@ -1000,7 +1006,7 @@
   }
 
   /* Free queue, but cls was freed by send_core_* */
-  GMP_queue_destroy (queue, GNUNET_NO, GNUNET_YES);
+  GMP_queue_destroy (queue, GNUNET_NO, GNUNET_YES, pid);
 
   /* If more data in queue, send next */
   queue = peer_get_first_message (peer);
@@ -1049,9 +1055,11 @@
  * @param queue Queue handler to cancel.
  * @param clear_cls Is it necessary to free associated cls?
  * @param sent Was it really sent? (Could have been canceled)
+ * @param pid PID, if relevant (was sent and was a payload message).
  */
 void
-GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent)
+GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls,
+                   int sent, uint32_t pid)
 {
   struct MeshPeer *peer;
 
@@ -1095,7 +1103,7 @@
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG, " calling callback\n");
     queue->callback (queue->callback_cls,
-                     queue->c, sent, queue->type,
+                     queue->c, sent, queue->type, pid,
                      queue->fwd, queue->size,
                      GNUNET_TIME_absolute_get_duration (queue->start_waiting));
   }
@@ -1241,7 +1249,7 @@
       }
       else
       {
-        GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO);
+        GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0);
       }
 
       /* Get next from prev, q->next might be already freed:
@@ -1326,13 +1334,13 @@
       case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN:
       case GNUNET_MESSAGE_TYPE_MESH_ACK:
       case GNUNET_MESSAGE_TYPE_MESH_POLL:
-        GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO);
+        GMP_queue_destroy (q, GNUNET_YES, GNUNET_NO, 0);
         continue;
 
       case GNUNET_MESSAGE_TYPE_MESH_KX:
       case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
         msg = (struct GNUNET_MessageHeader *) q->cls;
-        GMP_queue_destroy (q, GNUNET_NO, GNUNET_NO);
+        GMP_queue_destroy (q, GNUNET_NO, GNUNET_NO, 0);
         return msg;
 
       default:

Modified: gnunet/src/mesh/gnunet-service-mesh_peer.h
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_peer.h  2014-05-07 10:42:47 UTC (rev 
33179)
+++ gnunet/src/mesh/gnunet-service-mesh_peer.h  2014-05-07 10:42:51 UTC (rev 
33180)
@@ -59,13 +59,14 @@
  * @param c Connection this message was on.
  * @param sent Was it really sent? (Could have been canceled)
  * @param type Type of message sent.
+ * @param pid Packet ID, or 0 if not applicable (create, destroy, etc).
  * @param fwd Was this a FWD going message?
  * @param size Size of the message.
  * @param wait Time spent waiting for core (only the time for THIS message)
  */
 typedef void (*GMP_sent) (void *cls,
                           struct MeshConnection *c, int sent,
-                          uint16_t type, int fwd, size_t size,
+                          uint16_t type, uint32_t pid, int fwd, size_t size,
                           struct GNUNET_TIME_Relative wait);
 
 
/******************************************************************************/
@@ -127,9 +128,11 @@
  * @param queue Queue handler to cancel.
  * @param clear_cls Is it necessary to free associated cls?
  * @param sent Was it really sent? (Could have been canceled)
+ * @param pid PID, if relevant (was sent and was a payload message).
  */
 void
-GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls, int sent);
+GMP_queue_destroy (struct MeshPeerQueue *queue, int clear_cls,
+                   int sent, uint32_t pid);
 
 /**
  * @brief Queue and pass message to core when possible.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]