aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-06-05 18:21:59 +0000
committerBart Polot <bart@net.in.tum.de>2012-06-05 18:21:59 +0000
commit66a0ee143ded719ff56085e443e7ad3530eeb46f (patch)
tree451fe61e06143ebfd2ab0730eace12fa4a60898b /src
parent59a5fb24a1da9f89384eb9f279019cf1b5782697 (diff)
downloadgnunet-66a0ee143ded719ff56085e443e7ad3530eeb46f.tar.gz
gnunet-66a0ee143ded719ff56085e443e7ad3530eeb46f.zip
- make one global core queue
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh_new.c79
1 files changed, 45 insertions, 34 deletions
diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c
index 440183f12..7ff9f5e99 100644
--- a/src/mesh/gnunet-service-mesh_new.c
+++ b/src/mesh/gnunet-service-mesh_new.c
@@ -212,16 +212,6 @@ struct MeshPeerInfo
212 * Closure given to the DHT GET 212 * Closure given to the DHT GET
213 */ 213 */
214 struct MeshPathInfo *dhtgetcls; 214 struct MeshPathInfo *dhtgetcls;
215
216 /**
217 * Transmission queue to this peer, head
218 */
219 struct MeshPeerQueue *queue_head;
220
221 /**
222 * Transmission queue to this peer, tail
223 */
224 struct MeshPeerQueue *queue_tail;
225 215
226 /** 216 /**
227 * Array of tunnels this peer participates in 217 * Array of tunnels this peer participates in
@@ -235,11 +225,6 @@ struct MeshPeerInfo
235 * Number of tunnels this peers participates in 225 * Number of tunnels this peers participates in
236 */ 226 */
237 unsigned int ntunnels; 227 unsigned int ntunnels;
238
239 /**
240 * Handle to stop queued transmission
241 */
242 struct GNUNET_CORE_TransmitHandle *core_transmit;
243}; 228};
244 229
245 230
@@ -533,6 +518,12 @@ static struct MeshClient *clients;
533static struct MeshClient *clients_tail; 518static struct MeshClient *clients_tail;
534 519
535/** 520/**
521 * Transmission queue to core
522 */
523struct MeshPeerQueue *queue_head;
524struct MeshPeerQueue *queue_tail;
525
526/**
536 * Tunnels known, indexed by MESH_TunnelID (MeshTunnel) 527 * Tunnels known, indexed by MESH_TunnelID (MeshTunnel)
537 */ 528 */
538static struct GNUNET_CONTAINER_MultiHashMap *tunnels; 529static struct GNUNET_CONTAINER_MultiHashMap *tunnels;
@@ -548,15 +539,20 @@ static struct GNUNET_CONTAINER_MultiHashMap *incoming_tunnels;
548 */ 539 */
549static struct GNUNET_CONTAINER_MultiHashMap *peers; 540static struct GNUNET_CONTAINER_MultiHashMap *peers;
550 541
542/*
543 * Handle to communicate with transport
544 */
545// static struct GNUNET_TRANSPORT_Handle *transport_handle;
546
551/** 547/**
552 * Handle to communicate with core 548 * Handle to communicate with core
553 */ 549 */
554static struct GNUNET_CORE_Handle *core_handle; 550static struct GNUNET_CORE_Handle *core_handle;
555 551
556/** 552/**
557 * Handle to communicate with transport 553 * Handle to for queued transmissions
558 */ 554 */
559// static struct GNUNET_TRANSPORT_Handle *transport_handle; 555struct GNUNET_CORE_TransmitHandle *core_transmit;
560 556
561/** 557/**
562 * Handle to use DHT 558 * Handle to use DHT
@@ -2675,9 +2671,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
2675{ 2671{
2676 struct MeshTransmissionDescriptor *dd; 2672 struct MeshTransmissionDescriptor *dd;
2677 struct MeshPathInfo *path_info; 2673 struct MeshPathInfo *path_info;
2678 struct MeshPeerInfo *peer;
2679 2674
2680 peer = queue->peer;
2681 if (GNUNET_YES == clear_cls) 2675 if (GNUNET_YES == clear_cls)
2682 { 2676 {
2683 switch (queue->type) 2677 switch (queue->type)
@@ -2700,8 +2694,8 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls)
2700 } 2694 }
2701 GNUNET_free_non_null (queue->cls); 2695 GNUNET_free_non_null (queue->cls);
2702 } 2696 }
2703 GNUNET_CONTAINER_DLL_remove (peer->queue_head, peer->queue_tail, queue); 2697 GNUNET_CONTAINER_DLL_remove (queue_head, queue_tail, queue);
2704 GNUNET_free(queue); 2698 GNUNET_free (queue);
2705} 2699}
2706 2700
2707 2701
@@ -2721,8 +2715,8 @@ queue_send (void *cls, size_t size, void *buf)
2721 struct MeshPeerQueue *queue; 2715 struct MeshPeerQueue *queue;
2722 size_t data_size; 2716 size_t data_size;
2723 2717
2724 peer->core_transmit = NULL; 2718 core_transmit = NULL;
2725 queue = peer->queue_head; 2719 queue = queue_head;
2726 2720
2727 /* If queue is empty, send should have been cancelled */ 2721 /* If queue is empty, send should have been cancelled */
2728 if (NULL == queue) 2722 if (NULL == queue)
@@ -2737,7 +2731,7 @@ queue_send (void *cls, size_t size, void *buf)
2737 struct GNUNET_PeerIdentity id; 2731 struct GNUNET_PeerIdentity id;
2738 2732
2739 GNUNET_PEER_resolve (peer->id, &id); 2733 GNUNET_PEER_resolve (peer->id, &id);
2740 peer->core_transmit = 2734 core_transmit =
2741 GNUNET_CORE_notify_transmit_ready(core_handle, 2735 GNUNET_CORE_notify_transmit_ready(core_handle,
2742 0, 2736 0,
2743 0, 2737 0,
@@ -2777,18 +2771,18 @@ queue_send (void *cls, size_t size, void *buf)
2777 queue_destroy(queue, GNUNET_NO); 2771 queue_destroy(queue, GNUNET_NO);
2778 2772
2779 /* If more data in queue, send next */ 2773 /* If more data in queue, send next */
2780 if (NULL != peer->queue_head) 2774 if (NULL != queue_head)
2781 { 2775 {
2782 struct GNUNET_PeerIdentity id; 2776 struct GNUNET_PeerIdentity id;
2783 2777
2784 GNUNET_PEER_resolve (peer->id, &id); 2778 GNUNET_PEER_resolve (peer->id, &id);
2785 peer->core_transmit = 2779 core_transmit =
2786 GNUNET_CORE_notify_transmit_ready(core_handle, 2780 GNUNET_CORE_notify_transmit_ready(core_handle,
2787 0, 2781 0,
2788 0, 2782 0,
2789 GNUNET_TIME_UNIT_FOREVER_REL, 2783 GNUNET_TIME_UNIT_FOREVER_REL,
2790 &id, 2784 &id,
2791 peer->queue_head->size, 2785 queue_head->size,
2792 &queue_send, 2786 &queue_send,
2793 peer); 2787 peer);
2794 } 2788 }
@@ -2814,13 +2808,13 @@ queue_add (void *cls, uint16_t type, size_t size, struct MeshPeerInfo *dst)
2814 queue->type = type; 2808 queue->type = type;
2815 queue->size = size; 2809 queue->size = size;
2816 queue->peer = dst; 2810 queue->peer = dst;
2817 GNUNET_CONTAINER_DLL_insert_tail (dst->queue_head, dst->queue_tail, queue); 2811 GNUNET_CONTAINER_DLL_insert_tail (queue_head, queue_tail, queue);
2818 if (NULL == dst->core_transmit) 2812 if (NULL == core_transmit)
2819 { 2813 {
2820 struct GNUNET_PeerIdentity id; 2814 struct GNUNET_PeerIdentity id;
2821 2815
2822 GNUNET_PEER_resolve (dst->id, &id); 2816 GNUNET_PEER_resolve (dst->id, &id);
2823 dst->core_transmit = 2817 core_transmit =
2824 GNUNET_CORE_notify_transmit_ready(core_handle, 2818 GNUNET_CORE_notify_transmit_ready(core_handle,
2825 0, 2819 0,
2826 0, 2820 0,
@@ -4655,6 +4649,8 @@ static void
4655core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) 4649core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
4656{ 4650{
4657 struct MeshPeerInfo *pi; 4651 struct MeshPeerInfo *pi;
4652 struct MeshPeerQueue *q;
4653 struct MeshPeerQueue *n;
4658 4654
4659 DEBUG_CONN ("Peer disconnected\n"); 4655 DEBUG_CONN ("Peer disconnected\n");
4660 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); 4656 pi = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey);
@@ -4663,9 +4659,16 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
4663 GNUNET_break (0); 4659 GNUNET_break (0);
4664 return; 4660 return;
4665 } 4661 }
4666 while (NULL != pi->queue_head) 4662 q = queue_head;
4663 while (NULL != q)
4667 { 4664 {
4668 queue_destroy(pi->queue_head, GNUNET_YES); 4665 n = q->next;
4666 if (q->peer == pi)
4667 {
4668 /* try to reroute this traffic instead */
4669 queue_destroy(queue_head, GNUNET_YES);
4670 }
4671 q = n;
4669 } 4672 }
4670 peer_info_remove_path (pi, pi->id, myid); 4673 peer_info_remove_path (pi, pi->id, myid);
4671 if (myid == pi->id) 4674 if (myid == pi->id)
@@ -4711,10 +4714,18 @@ static int
4711shutdown_peer (void *cls, const GNUNET_HashCode * key, void *value) 4714shutdown_peer (void *cls, const GNUNET_HashCode * key, void *value)
4712{ 4715{
4713 struct MeshPeerInfo *p = value; 4716 struct MeshPeerInfo *p = value;
4717 struct MeshPeerQueue *q;
4718 struct MeshPeerQueue *n;
4714 4719
4715 while (NULL != p->queue_head) 4720 q = queue_head;
4721 while (NULL != q)
4716 { 4722 {
4717 queue_destroy(p->queue_head, GNUNET_YES); 4723 n = q->next;
4724 if (q->peer == p)
4725 {
4726 queue_destroy(queue_head, GNUNET_YES);
4727 }
4728 q = n;
4718 } 4729 }
4719 peer_info_destroy (p); 4730 peer_info_destroy (p);
4720 return GNUNET_YES; 4731 return GNUNET_YES;