gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r38206 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r38206 - gnunet/src/cadet
Date: Wed, 26 Oct 2016 06:20:50 +0200

Author: bartpolot
Date: 2016-10-26 06:20:49 +0200 (Wed, 26 Oct 2016)
New Revision: 38206

Modified:
   gnunet/src/cadet/gnunet-service-cadet_connection.c
Log:
- simplify connection-level processing of messages to be sent

Modified: gnunet/src/cadet/gnunet-service-cadet_connection.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-10-26 04:20:48 UTC 
(rev 38205)
+++ gnunet/src/cadet/gnunet-service-cadet_connection.c  2016-10-26 04:20:49 UTC 
(rev 38206)
@@ -1079,6 +1079,7 @@
   msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
   msg.cid = c->id;
+  msg.reserved = htonl (0);
   msg.peer1 = *id1;
   msg.peer2 = *id2;
   GNUNET_assert (NULL ==
@@ -1112,6 +1113,7 @@
   msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
   msg.cid = *connection_id;
+  msg.reserved = htonl (0);
   msg.peer1 = *id1;
   if (NULL != id2)
     msg.peer2 = *id2;
@@ -1412,7 +1414,7 @@
  * @param cls Closure (poll ctx).
  */
 static void
-connection_poll (void *cls);
+send_connection_poll (void *cls);
 
 
 /**
@@ -1450,7 +1452,7 @@
   GNUNET_assert (NULL == fc->poll_task);
   fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
   fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                &connection_poll,
+                                                &send_connection_poll,
                                                 fc);
   LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task);
 }
@@ -1463,7 +1465,7 @@
  * @param cls Closure (poll ctx).
  */
 static void
-connection_poll (void *cls)
+send_connection_poll (void *cls)
 {
   struct CadetFlowControl *fc = cls;
   struct GNUNET_CADET_Poll msg;
@@ -1479,6 +1481,7 @@
 
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_POLL);
   msg.header.size = htons (sizeof (msg));
+  msg.cid = c->id;
   msg.pid = htonl (fc->last_pid_sent);
   LOG (GNUNET_ERROR_TYPE_DEBUG, " last pid sent: %u\n", fc->last_pid_sent);
   fc->poll_msg =
@@ -3259,15 +3262,10 @@
 {
   struct GNUNET_CADET_AX        *axmsg;
   struct GNUNET_CADET_KX        *kmsg;
-  struct GNUNET_CADET_ACK       *amsg;
-  struct GNUNET_CADET_Poll      *pmsg;
-  struct GNUNET_CADET_ConnectionDestroy *dmsg;
-  struct GNUNET_CADET_ConnectionBroken  *bmsg;
   struct CadetFlowControl *fc;
   struct CadetConnectionQueue *q;
   size_t size;
   uint16_t type;
-  int droppable;
 
   GCC_check_connections ();
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
@@ -3283,7 +3281,6 @@
        "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n",
        GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c,
        GC_f2s(fwd), size);
-  droppable = (GNUNET_NO == force);
   switch (type)
   {
     case GNUNET_MESSAGE_TYPE_CADET_AX:
@@ -3293,13 +3290,13 @@
       LOG (GNUNET_ERROR_TYPE_DEBUG, "  Q_N+ %p %u\n", fc, fc->queue_n);
       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)
+      if (GNUNET_NO == force)
       {
         fc->queue_n++;
       }
       else
       {
-        LOG (GNUNET_ERROR_TYPE_DEBUG, "  not droppable, Q_N stays the same\n");
+        LOG (GNUNET_ERROR_TYPE_DEBUG, "  forced msg, Q_N stays the same\n");
       }
       break;
 
@@ -3309,43 +3306,24 @@
       kmsg->cid = c->id;
       break;
 
-    case GNUNET_MESSAGE_TYPE_CADET_ACK:
-      amsg = (struct GNUNET_CADET_ACK *) message;
-      amsg->cid = c->id;
-      LOG (GNUNET_ERROR_TYPE_DEBUG, " ack %u\n", ntohl (amsg->ack));
-      droppable = GNUNET_NO;
+    case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE:
+    case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK:
+      GNUNET_break (0); /* Should've used specific functions. */
       break;
 
+    case GNUNET_MESSAGE_TYPE_CADET_ACK:
     case GNUNET_MESSAGE_TYPE_CADET_POLL:
-      pmsg = (struct GNUNET_CADET_Poll *) message;
-      pmsg->cid = c->id;
-      LOG (GNUNET_ERROR_TYPE_DEBUG, " POLL %u\n", ntohl (pmsg->pid));
-      droppable = GNUNET_NO;
-      break;
-
     case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY:
-      dmsg = (struct GNUNET_CADET_ConnectionDestroy *) message;
-      dmsg->reserved = htonl (0);
-      dmsg->cid = c->id;
-      break;
-
     case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN:
-      bmsg = (struct GNUNET_CADET_ConnectionBroken *) message;
-      bmsg->reserved = htonl (0);
-      bmsg->cid = c->id;
+      GNUNET_assert (GNUNET_YES == force);
       break;
 
-    case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE:
-    case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK:
-      GNUNET_break (0); /* Should've used specific functions. */
-      break;
-
     default:
       GNUNET_break (0);
       return NULL;
   }
 
-  if (fc->queue_n > fc->queue_max && droppable)
+  if (fc->queue_n > fc->queue_max && GNUNET_NO == force)
   {
     GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)",
                               1, GNUNET_NO);
@@ -3364,7 +3342,7 @@
   c->pending_messages++;
 
   q = GNUNET_new (struct CadetConnectionQueue);
-  q->forced = !droppable;
+  q->forced = force;
   q->peer_q = GCP_send (get_hop (c, fwd), message,
                         payload_type, payload_id,
                         c, fwd,
@@ -3410,7 +3388,8 @@
   uint16_t size;
 
   /* Allocate a copy of the message on the stack, so we can modify it as 
needed,
-   * adding the Connection ID.
+   * adding the Connection ID, PID, and other data the Tunnel layer doesn't
+   * have access to.
    */
   size = ntohs (message->size);
   {
@@ -3585,6 +3564,7 @@
   msg.header.size = htons (sizeof (msg));
   msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY);
   msg.cid = c->id;
+  msg.reserved = htonl (0);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
               "  sending connection destroy for connection %s\n",
               GCC_2s (c));
@@ -3635,7 +3615,7 @@
   }
   LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL started on request\n");
   fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
-                                                &connection_poll,
+                                                &send_connection_poll,
                                                 fc);
 }
 




reply via email to

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