From: Bart Polot Date: Fri, 29 Nov 2013 12:30:56 +0000 (+0000) Subject: - do not count channel management traffic as payload X-Git-Tag: initial-import-from-subversion-38251~5862 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f88fa25e5c577cd6260e19bac428fa1f2fe4edd2;p=oweals%2Fgnunet.git - do not count channel management traffic as payload --- diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 13def7e17..409172c34 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -221,6 +221,11 @@ struct MeshConnectionQueue */ struct MeshPeerQueue *q; + /** + * Was this a forced message? (Do not account for it) + */ + int forced; + /** * Continuation to call once sent. */ @@ -527,6 +532,7 @@ message_sent (void *cls, struct MeshFlowControl *fc; struct MeshConnectionQueue *q = cls; double usecsperbyte; + int forced; fc = fwd ? &c->fwd_fc : &c->bck_fc; LOG (GNUNET_ERROR_TYPE_DEBUG, @@ -536,6 +542,7 @@ message_sent (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "! C_P- %p %u\n", c, c->pending_messages); if (NULL != q) { + forced = q->forced; if (NULL != q->cont) { LOG (GNUNET_ERROR_TYPE_DEBUG, "! calling cont\n"); @@ -543,6 +550,15 @@ message_sent (void *cls, } GNUNET_free (q); } + else if (type == GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED) + { + /* If NULL == q and ENCRYPTED == type, message must have been ch_mngmnt */ + forced = GNUNET_YES; + } + else + { + forced = GNUNET_NO; + } c->pending_messages--; if (GNUNET_YES == c->destroy && 0 == c->pending_messages) { @@ -556,10 +572,19 @@ 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", - fc->last_pid_sent); + if (GNUNET_NO == forced) + { + fc->queue_n--; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "! accounting pid %u\n", + fc->last_pid_sent); + } + else + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "! forced, Q_N not accounting pid %u\n", + fc->last_pid_sent); + } GMC_send_ack (c, fwd, GNUNET_NO); break; @@ -2545,10 +2570,17 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, emsg->ttl = htonl (ttl - 1); emsg->pid = htonl (fc->next_pid++); LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n); - fc->queue_n++; - LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", ntohl (emsg->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) + { + fc->queue_n++; + LOG (GNUNET_ERROR_TYPE_DEBUG, "pid %u\n", ntohl (emsg->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); + } + else + { + LOG (GNUNET_ERROR_TYPE_DEBUG, " not droppable, Q_N stays the same\n"); + } if (GM_is_pid_bigger (fc->last_pid_sent + 1, fc->last_ack_recv)) { GMC_start_poll (c, fwd); @@ -2617,14 +2649,8 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u\n", c, c->pending_messages); c->pending_messages++; - if (NULL == cont) - { - (void) GMP_queue_add (get_hop (c, fwd), data, type, size, c, fwd, - &message_sent, NULL); - return NULL; - } - q = GNUNET_new (struct MeshConnectionQueue); + q->forced = !droppable; q->q = GMP_queue_add (get_hop (c, fwd), data, type, size, c, fwd, &message_sent, q); if (NULL == q->q)