diff options
author | Bart Polot <bart@net.in.tum.de> | 2016-03-30 09:17:55 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2016-03-30 09:17:55 +0000 |
commit | 19d0f50eb17321a1beb0e3651ca192f398fe179d (patch) | |
tree | ed2dd8e984e1c84524ffeec2ef5071306f7ce6f3 | |
parent | 03bac82f91ddb103b29804503b2d931d0e4d1fab (diff) |
- refactor, test orderd
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 28 | ||||
-rw-r--r-- | 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 @@ -464,20 +464,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. * * @param c Connection to change. @@ -502,6 +488,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. * * @param cls Closure (FC). 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; |