From 19d0f50eb17321a1beb0e3651ca192f398fe179d Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Wed, 30 Mar 2016 09:17:55 +0000 Subject: - refactor, test orderd --- src/cadet/gnunet-service-cadet_connection.c | 28 ++++++++++++++-------------- src/cadet/gnunet-service-cadet_peer.c | 25 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 54b7561edf..3dbb709695 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -463,20 +463,6 @@ connection_get (const struct GNUNET_CADET_Hash *cid) } -/** - * Mark a connection as "destroyed", to send all pending traffic and freeing - * all associated resources, without accepting new status changes on it. - * - * @param c Connection to mark as destroyed. - */ -static void -mark_destroyed (struct CadetConnection *c) -{ - c->destroy = GNUNET_YES; - connection_change_state (c, CADET_CONNECTION_DESTROYED); -} - - /** * Change the connection state. Cannot change a connection marked as destroyed. * @@ -501,6 +487,20 @@ connection_change_state (struct CadetConnection* c, } +/** + * Mark a connection as "destroyed", to send all pending traffic and freeing + * all associated resources, without accepting new status changes on it. + * + * @param c Connection to mark as destroyed. + */ +static void +mark_destroyed (struct CadetConnection *c) +{ + c->destroy = GNUNET_YES; + connection_change_state (c, CADET_CONNECTION_DESTROYED); +} + + /** * Callback called when a queued ACK message is sent. * diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index b2dabf0872..f1ba2cfdef 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c @@ -1091,6 +1091,21 @@ get_core_size (size_t message_size) return message_size + sizeof (struct GNUNET_CADET_ACK); } +/** + * Test if a message type is connection management traffic + * or regular payload traffic. + * + * @param type Message type. + * + * @return #GNUNET_YES if connection management, #GNUNET_NO otherwise. + */ +static int +is_connection_management (uint16_t type) +{ + return type == GNUNET_MESSAGE_TYPE_CADET_ACK || + type == GNUNET_MESSAGE_TYPE_CADET_POLL; +} + /** * Fill a core buffer with the appropriate data for the queued message. @@ -1410,8 +1425,7 @@ GCP_queue_destroy (struct CadetPeerQueue *queue, } GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue); - if (queue->type != GNUNET_MESSAGE_TYPE_CADET_ACK && - queue->type != GNUNET_MESSAGE_TYPE_CADET_POLL) + if (!is_connection_management (queue->type)) { peer->queue_n--; } @@ -1497,16 +1511,13 @@ GCP_queue_add (struct CadetPeer *peer, } priority = 0; - - if (GNUNET_MESSAGE_TYPE_CADET_POLL == type || - GNUNET_MESSAGE_TYPE_CADET_ACK == type) + if (is_connection_management (type)) { priority = 100; } - LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); - call_core = (NULL == c || type == GNUNET_MESSAGE_TYPE_CADET_KX) ? + call_core = (NULL == c || GNUNET_MESSAGE_TYPE_CADET_KX == type) ? GNUNET_YES : GCC_is_sendable (c, fwd); q = GNUNET_new (struct CadetPeerQueue); q->cls = cls; -- cgit v1.2.3-18-g5258