From 234e8b3799734868d6eb56b752996a6bff97c836 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 8 Nov 2013 12:09:54 +0000 Subject: [PATCH] - fix polling --- src/mesh/gnunet-service-mesh_channel.c | 5 +++-- src/mesh/gnunet-service-mesh_connection.c | 14 +++++++------- src/mesh/gnunet-service-mesh_peer.c | 21 +++++---------------- src/mesh/gnunet-service-mesh_tunnel.c | 1 + 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_channel.c b/src/mesh/gnunet-service-mesh_channel.c index d3e78efa5..617c8e357 100644 --- a/src/mesh/gnunet-service-mesh_channel.c +++ b/src/mesh/gnunet-service-mesh_channel.c @@ -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; } diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index b66b9299b..8920ac58f 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -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; diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 0b60693b2..a934ccc72 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -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) diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index de41da747..68e9d8684 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -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: -- 2.25.1