From 851903da372fa136ff783bc92c3abe57f554786e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 17 Jan 2012 14:45:05 +0000 Subject: [PATCH] -track tmq queue length --- src/vpn/gnunet-service-vpn.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/vpn/gnunet-service-vpn.c b/src/vpn/gnunet-service-vpn.c index 2f7e16741..bb6e6c595 100644 --- a/src/vpn/gnunet-service-vpn.c +++ b/src/vpn/gnunet-service-vpn.c @@ -195,7 +195,7 @@ struct TunnelState /** * Tail of list of messages scheduled for transmission. */ - struct TunnelMessageQueueEntry *tmq_tail; + struct TunnelMessageQueueEntry *tmq_tail; /** * Client that needs to be notified about the tunnel being @@ -203,6 +203,12 @@ struct TunnelState */ struct GNUNET_SERVER_Client *client; + /** + * Destination entry that has a pointer to this tunnel state; + * NULL if this tunnel state is in the tunnel map. + */ + struct DestinationEntry *destination_container; + /** * ID of the client request that caused us to setup this entry. */ @@ -217,15 +223,14 @@ struct TunnelState struct DestinationEntry destination; /** - * Destination entry that has a pointer to this tunnel state; - * NULL if this tunnel state is in the tunnel map. + * Addess family used for this tunnel on the local TUN interface. */ - struct DestinationEntry *destination_container; + int af; /** - * Addess family used for this tunnel on the local TUN interface. + * Length of the doubly linked 'tmq_head/tmq_tail' list. */ - int af; + unsigned int tmq_length; /** * IPPROTO_TCP or IPPROTO_UDP once bound. @@ -577,6 +582,7 @@ send_to_peer_notify_callback (void *cls, size_t size, void *buf) GNUNET_CONTAINER_DLL_remove (ts->tmq_head, ts->tmq_tail, tnq); + ts->tmq_length--; memcpy (buf, tnq->msg, tnq->len); ret = tnq->len; GNUNET_free (tnq); @@ -615,6 +621,7 @@ send_to_tunnel (struct TunnelMessageQueueEntry *tnq, GNUNET_CONTAINER_DLL_insert_tail (ts->tmq_head, ts->tmq_tail, tnq); + ts->tmq_length++; if (NULL == ts->th) ts->th = GNUNET_MESH_notify_transmit_ready (ts->tunnel, GNUNET_NO /* cork */, @@ -1972,8 +1979,10 @@ free_tunnel_state (struct TunnelState *ts) GNUNET_CONTAINER_DLL_remove (ts->tmq_head, ts->tmq_tail, tnq); + ts->tmq_length--; GNUNET_free (tnq); } + GNUNET_assert (0 == ts->tmq_length); if (NULL != ts->client) { GNUNET_SERVER_client_drop (ts->client); -- 2.25.1