diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-10-10 12:46:15 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-10-10 12:46:15 +0000 |
commit | 0f4a34c3c534fc01ded8ea3d94b990ca09d7ac0b (patch) | |
tree | d096fb06a2a5dc8d7d74a5f48717fe27a2c706bf /src/mesh | |
parent | 28d38d5c3a001d874c872bbde8b3d01f2df6c6d6 (diff) | |
download | gnunet-0f4a34c3c534fc01ded8ea3d94b990ca09d7ac0b.tar.gz gnunet-0f4a34c3c534fc01ded8ea3d94b990ca09d7ac0b.zip |
- move queue canceling to peer.c
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh_connection.c | 32 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.c | 41 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh_peer.h | 17 |
3 files changed, 65 insertions, 25 deletions
diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index e70211cb9..d7d6f89f7 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c | |||
@@ -723,8 +723,7 @@ connection_unlock_queue (struct MeshConnection *c, int fwd) | |||
723 | static void | 723 | static void |
724 | connection_cancel_queues (struct MeshConnection *c, int fwd) | 724 | connection_cancel_queues (struct MeshConnection *c, int fwd) |
725 | { | 725 | { |
726 | struct MeshPeerQueue *q; | 726 | |
727 | struct MeshPeerQueue *next; | ||
728 | struct MeshFlowControl *fc; | 727 | struct MeshFlowControl *fc; |
729 | struct MeshPeer *peer; | 728 | struct MeshPeer *peer; |
730 | 729 | ||
@@ -733,32 +732,15 @@ connection_cancel_queues (struct MeshConnection *c, int fwd) | |||
733 | GNUNET_break (0); | 732 | GNUNET_break (0); |
734 | return; | 733 | return; |
735 | } | 734 | } |
736 | fc = fwd ? &c->fwd_fc : &c->bck_fc; | 735 | |
737 | peer = connection_get_hop (c, fwd); | 736 | peer = connection_get_hop (c, fwd); |
737 | GMP_queue_cancel (peer, c); | ||
738 | 738 | ||
739 | for (q = peer->queue_head; NULL != q; q = next) | 739 | fc = fwd ? &c->fwd_fc : &c->bck_fc; |
740 | { | 740 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task) |
741 | next = q->next; | ||
742 | if (q->c == c) | ||
743 | { | ||
744 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
745 | "connection_cancel_queue %s\n", | ||
746 | GNUNET_MESH_DEBUG_M2S (q->type)); | ||
747 | queue_destroy (q, GNUNET_YES); | ||
748 | } | ||
749 | } | ||
750 | if (NULL == peer->queue_head) | ||
751 | { | 741 | { |
752 | if (NULL != peer->core_transmit) | 742 | GNUNET_SCHEDULER_cancel (fc->poll_task); |
753 | { | 743 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; |
754 | GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit); | ||
755 | peer->core_transmit = NULL; | ||
756 | } | ||
757 | if (GNUNET_SCHEDULER_NO_TASK != fc->poll_task) | ||
758 | { | ||
759 | GNUNET_SCHEDULER_cancel (fc->poll_task); | ||
760 | fc->poll_task = GNUNET_SCHEDULER_NO_TASK; | ||
761 | } | ||
762 | } | 744 | } |
763 | } | 745 | } |
764 | 746 | ||
diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index d700f3aa2..5e44bbc86 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c | |||
@@ -1407,6 +1407,39 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | 1409 | ||
1410 | /** | ||
1411 | * Cancel all queued messages to a peer that belong to a certain connection. | ||
1412 | * | ||
1413 | * @param peer Peer towards whom to cancel. | ||
1414 | * @param c Connection whose queued messages to cancel. | ||
1415 | */ | ||
1416 | void | ||
1417 | GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c) | ||
1418 | { | ||
1419 | struct MeshPeerQueue *q; | ||
1420 | struct MeshPeerQueue *next; | ||
1421 | |||
1422 | for (q = peer->queue_head; NULL != q; q = next) | ||
1423 | { | ||
1424 | next = q->next; | ||
1425 | if (q->c == c) | ||
1426 | { | ||
1427 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1428 | "connection_cancel_queue %s\n", | ||
1429 | GNUNET_MESH_DEBUG_M2S (q->type)); | ||
1430 | GMP_queue_destroy (q, GNUNET_YES); | ||
1431 | } | ||
1432 | } | ||
1433 | if (NULL == peer->queue_head) | ||
1434 | { | ||
1435 | if (NULL != peer->core_transmit) | ||
1436 | { | ||
1437 | GNUNET_CORE_notify_transmit_ready_cancel (peer->core_transmit); | ||
1438 | peer->core_transmit = NULL; | ||
1439 | } | ||
1440 | } | ||
1441 | } | ||
1442 | |||
1410 | 1443 | ||
1411 | /** | 1444 | /** |
1412 | * Initialize the peer subsystem. | 1445 | * Initialize the peer subsystem. |
@@ -1624,6 +1657,14 @@ GMP_add_connection (struct MeshPeer *peer, | |||
1624 | } | 1657 | } |
1625 | 1658 | ||
1626 | 1659 | ||
1660 | /** | ||
1661 | * Remove a connection from a neighboring peer. | ||
1662 | * | ||
1663 | * @param peer Peer to remove connection from. | ||
1664 | * @param c Connection to remove. | ||
1665 | * | ||
1666 | * @return GNUNET_OK on success. | ||
1667 | */ | ||
1627 | int | 1668 | int |
1628 | GMP_remove_connection (struct MeshPeer *peer, | 1669 | GMP_remove_connection (struct MeshPeer *peer, |
1629 | const struct MeshConnection *c) | 1670 | const struct MeshConnection *c) |
diff --git a/src/mesh/gnunet-service-mesh_peer.h b/src/mesh/gnunet-service-mesh_peer.h index ad1955390..c898af351 100644 --- a/src/mesh/gnunet-service-mesh_peer.h +++ b/src/mesh/gnunet-service-mesh_peer.h | |||
@@ -98,6 +98,15 @@ GMP_queue_add (void *cls, uint16_t type, size_t size, | |||
98 | GMP_sent callback, void *callback_cls); | 98 | GMP_sent callback, void *callback_cls); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Cancel all queued messages to a peer that belong to a certain connection. | ||
102 | * | ||
103 | * @param peer Peer towards whom to cancel. | ||
104 | * @param c Connection whose queued messages to cancel. | ||
105 | */ | ||
106 | void | ||
107 | GMP_queue_cancel (struct MeshPeer *peer, struct MeshConnection *c); | ||
108 | |||
109 | /** | ||
101 | * Set tunnel. | 110 | * Set tunnel. |
102 | * | 111 | * |
103 | * @param peer Peer. | 112 | * @param peer Peer. |
@@ -132,6 +141,14 @@ GMP_is_neighbor (const struct MeshPeer *peer); | |||
132 | int | 141 | int |
133 | GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c); | 142 | GMP_add_connection (struct MeshPeer *peer, struct MeshConnection *c); |
134 | 143 | ||
144 | /** | ||
145 | * Remove a connection from a neighboring peer. | ||
146 | * | ||
147 | * @param peer Peer to remove connection from. | ||
148 | * @param c Connection to remove. | ||
149 | * | ||
150 | * @return GNUNET_OK on success. | ||
151 | */ | ||
135 | int | 152 | int |
136 | GMP_remove_connection (struct MeshPeer *peer, struct MeshConnection *c); | 153 | GMP_remove_connection (struct MeshPeer *peer, struct MeshConnection *c); |
137 | 154 | ||