- fix polling
authorBart Polot <bart@net.in.tum.de>
Fri, 8 Nov 2013 12:09:54 +0000 (12:09 +0000)
committerBart Polot <bart@net.in.tum.de>
Fri, 8 Nov 2013 12:09:54 +0000 (12:09 +0000)
src/mesh/gnunet-service-mesh_channel.c
src/mesh/gnunet-service-mesh_connection.c
src/mesh/gnunet-service-mesh_peer.c
src/mesh/gnunet-service-mesh_tunnel.c

index d3e78efa53fa1ec0d8b6675e4635fd3fc06bdb63..617c8e357d5641e5a12b2cb0bd201636102603f0 100644 (file)
@@ -1629,7 +1629,8 @@ GMCH_handle_data_ack (struct MeshChannel *ch,
       GNUNET_break (0);
       return;
     }
-    fwd = (NULL != ch->dest) ? GNUNET_YES : GNUNET_NO;
+    /* Inverted: if message came 'FWD' is a 'BCK ACK'. */
+    fwd = (NULL != ch->dest) ? GNUNET_NO : GNUNET_YES;
   }
 
   ack = ntohl (msg->mid);
@@ -1646,7 +1647,7 @@ GMCH_handle_data_ack (struct MeshChannel *ch,
   }
   if (NULL == rel)
   {
-    GNUNET_break (0);
+    GNUNET_break_op (0);
     return;
   }
 
index b66b9299b69eec93cac9de25bfc94d56ffa207e0..8920ac58f126d48a045a9a80b37340ea1adf5222 100644 (file)
@@ -445,7 +445,6 @@ message_sent (void *cls,
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!  sent %s\n", GNUNET_MESH_DEBUG_M2S (type));
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "!  Q_N- %p %u\n", fc, fc->queue_n);
   LOG (GNUNET_ERROR_TYPE_DEBUG, "!  C_P- %p %u\n", c, c->pending_messages);
   c->pending_messages--;
   if (GNUNET_YES == c->destroy && 0 == c->pending_messages)
@@ -459,6 +458,7 @@ message_sent (void *cls,
   {
     case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED:
       fc->last_pid_sent++;
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "!  Q_N- %p %u\n", fc, fc->queue_n);
       fc->queue_n--;
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "!   accounting pid %u\n",
@@ -604,6 +604,7 @@ send_connection_ack (struct MeshConnection *connection, int fwd)
                  GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK,
                  sizeof (struct GNUNET_MESH_ConnectionACK),
                  connection, fwd, &message_sent, NULL);
+  connection->pending_messages++;
   if (MESH_TUNNEL3_NEW == GMT_get_state (t))
     GMT_change_state (t, MESH_TUNNEL3_WAITING);
   if (MESH_CONNECTION_READY != connection->state)
@@ -1724,12 +1725,12 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
   id = GNUNET_PEER_search (peer);
   if (GMP_get_short_id (get_next_hop (c)) == id)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "  FWD ACK\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  FWD FC\n");
     fc = &c->fwd_fc;
   }
   else if (GMP_get_short_id (get_prev_hop (c)) == id)
   {
-    LOG (GNUNET_ERROR_TYPE_DEBUG, "  BCK ACK\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "  BCK FC\n");
     fc = &c->bck_fc;
   }
   else
@@ -1739,10 +1740,9 @@ GMC_handle_poll (void *cls, const struct GNUNET_PeerIdentity *peer,
   }
 
   pid = ntohl (msg->pid);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "  PID %u, OLD %u\n",
-              pid, fc->last_pid_recv);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "  PID %u, OLD %u\n", pid, fc->last_pid_recv);
   fc->last_pid_recv = pid;
-  fwd = fc == &c->fwd_fc;
+  fwd = fc == &c->bck_fc;
   GMC_send_ack (c, fwd);
 
   return GNUNET_OK;
@@ -2230,7 +2230,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
   data = GNUNET_malloc (size);
   memcpy (data, message, size);
   type = ntohs (message->type);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u) on connection %s\n",
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Send %s (%u bytes) on connection %s\n",
               GNUNET_MESH_DEBUG_M2S (type), size, GMC_2s (c));
 
   fc = fwd ? &c->fwd_fc : &c->bck_fc;
index 0b60693b2c449db2c7f03534054402c0a9ee3806..a934ccc7289e94466c7306082279f2233ddd4b4a 100644 (file)
@@ -1008,26 +1008,15 @@ GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size,
   queue->fwd = fwd;
   queue->callback = cont;
   queue->callback_cls = cont_cls;
-  if (100 <= priority)
+  if (100 > priority)
   {
-    struct MeshPeerQueue *copy;
-    struct MeshPeerQueue *next;
-
-    for (copy = peer->queue_head; NULL != copy; copy = next)
-    {
-      next = copy->next;
-      if (copy->type == type && copy->c == c && copy->fwd == fwd)
-      {
-        /* Example: also a FWD ACK for connection XYZ */
-        queue_destroy (copy, GNUNET_YES);
-      }
-    }
-    GNUNET_CONTAINER_DLL_insert (peer->queue_head, peer->queue_tail, queue);
+    GNUNET_CONTAINER_DLL_insert_tail (peer->queue_head, peer->queue_tail, queue);
+    peer->queue_n++;
   }
   else
   {
-    GNUNET_CONTAINER_DLL_insert_tail (peer->queue_head, peer->queue_tail, queue);
-    peer->queue_n++;
+    GNUNET_CONTAINER_DLL_insert (peer->queue_head, peer->queue_tail, queue);
+    call_core = GNUNET_YES;
   }
 
   if (NULL == peer->core_transmit && GNUNET_YES == call_core)
index de41da747776970a321f8e773606c6c7d367343c..68e9d868405e8769d84c3c1e11bca9206f9552fc 100644 (file)
@@ -2007,6 +2007,7 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
   switch (type)
   {
     case GNUNET_MESSAGE_TYPE_MESH_DATA:
+    case GNUNET_MESSAGE_TYPE_MESH_DATA_ACK:
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE:
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
     case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: