aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2016-03-30 09:17:55 +0000
committerBart Polot <bart@net.in.tum.de>2016-03-30 09:17:55 +0000
commit19d0f50eb17321a1beb0e3651ca192f398fe179d (patch)
treeed2dd8e984e1c84524ffeec2ef5071306f7ce6f3
parent03bac82f91ddb103b29804503b2d931d0e4d1fab (diff)
downloadgnunet-19d0f50eb17321a1beb0e3651ca192f398fe179d.tar.gz
gnunet-19d0f50eb17321a1beb0e3651ca192f398fe179d.zip
- refactor, test orderd
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c28
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c25
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 54b7561ed..3dbb70969 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)
464 464
465 465
466/** 466/**
467 * Mark a connection as "destroyed", to send all pending traffic and freeing
468 * all associated resources, without accepting new status changes on it.
469 *
470 * @param c Connection to mark as destroyed.
471 */
472static void
473mark_destroyed (struct CadetConnection *c)
474{
475 c->destroy = GNUNET_YES;
476 connection_change_state (c, CADET_CONNECTION_DESTROYED);
477}
478
479
480/**
481 * Change the connection state. Cannot change a connection marked as destroyed. 467 * Change the connection state. Cannot change a connection marked as destroyed.
482 * 468 *
483 * @param c Connection to change. 469 * @param c Connection to change.
@@ -502,6 +488,20 @@ connection_change_state (struct CadetConnection* c,
502 488
503 489
504/** 490/**
491 * Mark a connection as "destroyed", to send all pending traffic and freeing
492 * all associated resources, without accepting new status changes on it.
493 *
494 * @param c Connection to mark as destroyed.
495 */
496static void
497mark_destroyed (struct CadetConnection *c)
498{
499 c->destroy = GNUNET_YES;
500 connection_change_state (c, CADET_CONNECTION_DESTROYED);
501}
502
503
504/**
505 * Callback called when a queued ACK message is sent. 505 * Callback called when a queued ACK message is sent.
506 * 506 *
507 * @param cls Closure (FC). 507 * @param cls Closure (FC).
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index b2dabf087..f1ba2cfde 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)
1091 return message_size + sizeof (struct GNUNET_CADET_ACK); 1091 return message_size + sizeof (struct GNUNET_CADET_ACK);
1092} 1092}
1093 1093
1094/**
1095 * Test if a message type is connection management traffic
1096 * or regular payload traffic.
1097 *
1098 * @param type Message type.
1099 *
1100 * @return #GNUNET_YES if connection management, #GNUNET_NO otherwise.
1101 */
1102static int
1103is_connection_management (uint16_t type)
1104{
1105 return type == GNUNET_MESSAGE_TYPE_CADET_ACK ||
1106 type == GNUNET_MESSAGE_TYPE_CADET_POLL;
1107}
1108
1094 1109
1095/** 1110/**
1096 * Fill a core buffer with the appropriate data for the queued message. 1111 * Fill a core buffer with the appropriate data for the queued message.
@@ -1410,8 +1425,7 @@ GCP_queue_destroy (struct CadetPeerQueue *queue,
1410 } 1425 }
1411 GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue); 1426 GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue);
1412 1427
1413 if (queue->type != GNUNET_MESSAGE_TYPE_CADET_ACK && 1428 if (!is_connection_management (queue->type))
1414 queue->type != GNUNET_MESSAGE_TYPE_CADET_POLL)
1415 { 1429 {
1416 peer->queue_n--; 1430 peer->queue_n--;
1417 } 1431 }
@@ -1497,16 +1511,13 @@ GCP_queue_add (struct CadetPeer *peer,
1497 } 1511 }
1498 1512
1499 priority = 0; 1513 priority = 0;
1500 1514 if (is_connection_management (type))
1501 if (GNUNET_MESSAGE_TYPE_CADET_POLL == type ||
1502 GNUNET_MESSAGE_TYPE_CADET_ACK == type)
1503 { 1515 {
1504 priority = 100; 1516 priority = 100;
1505 } 1517 }
1506
1507 LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); 1518 LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority);
1508 1519
1509 call_core = (NULL == c || type == GNUNET_MESSAGE_TYPE_CADET_KX) ? 1520 call_core = (NULL == c || GNUNET_MESSAGE_TYPE_CADET_KX == type) ?
1510 GNUNET_YES : GCC_is_sendable (c, fwd); 1521 GNUNET_YES : GCC_is_sendable (c, fwd);
1511 q = GNUNET_new (struct CadetPeerQueue); 1522 q = GNUNET_new (struct CadetPeerQueue);
1512 q->cls = cls; 1523 q->cls = cls;