aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-08-02 02:03:09 +0000
committerBart Polot <bart@net.in.tum.de>2013-08-02 02:03:09 +0000
commit6190a95ec24eed69b9657646e242d3eb92e602e3 (patch)
treeab2af8f415994cb6155a4833adc011a0d2bfedaf /src
parent52c9612e0a1c2ce12ac079836a7e8255c82e7823 (diff)
downloadgnunet-6190a95ec24eed69b9657646e242d3eb92e602e3.tar.gz
gnunet-6190a95ec24eed69b9657646e242d3eb92e602e3.zip
- queue_add, priorities
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c89
1 files changed, 34 insertions, 55 deletions
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index 57a0cdf3e..57bccb29b 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -4074,43 +4074,43 @@ queue_add (void *cls, uint16_t type, size_t size,
4074{ 4074{
4075 struct MeshPeerQueue *queue; 4075 struct MeshPeerQueue *queue;
4076 struct MeshFlowControl *fc; 4076 struct MeshFlowControl *fc;
4077 struct MeshTunnel2 *t;
4078 int priority; 4077 int priority;
4079 4078
4080 fc = NULL; 4079 fc = dst->fc;
4081 priority = GNUNET_NO; 4080 if (NULL == fc)
4082 if (GNUNET_MESSAGE_TYPE_MESH_UNICAST == type ||
4083 GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type)
4084 { 4081 {
4085 fc = dst->fc; 4082 GNUNET_break (0);
4083 return;
4086 } 4084 }
4087 if (NULL != fc) 4085
4086 priority = 0;
4087
4088 if (GNUNET_MESSAGE_TYPE_MESH_POLL == type ||
4089 GNUNET_MESSAGE_TYPE_MESH_ACK == type)
4090 priority = 100;
4091
4092 if (NULL != ch &&
4093 ( (NULL != ch->owner && GNUNET_MESSAGE_TYPE_MESH_FWD == type) ||
4094 (NULL != ch->client && GNUNET_MESSAGE_TYPE_MESH_BCK == type) ))
4095 priority = 50;
4096
4097 if (fc->queue_n >= fc->queue_max && 0 == priority)
4088 { 4098 {
4089 if (fc->queue_n >= fc->queue_max) 4099 GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)",
4090 { 4100 1, GNUNET_NO);
4091 /* If this isn't a retransmission, drop the message */ 4101 GNUNET_break (0);
4092 if (NULL != ch && 4102 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4093 (GNUNET_NO == ch->reliable || 4103 "queue full: %u/%u\n",
4094 (NULL == ch->owner && GNUNET_MESSAGE_TYPE_MESH_UNICAST == type) || 4104 fc->queue_n, fc->queue_max);
4095 (NULL == ch->client && GNUNET_MESSAGE_TYPE_MESH_TO_ORIGIN == type))) 4105 return; /* Drop this message */
4096 {
4097 GNUNET_STATISTICS_update (stats, "# messages dropped (buffer full)",
4098 1, GNUNET_NO);
4099 GNUNET_break (0);
4100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4101 "queue full: %u/%u\n",
4102 fc->queue_n, fc->queue_max);
4103 return; /* Drop this message */
4104 }
4105 priority = GNUNET_YES;
4106 }
4107 fc->queue_n++;
4108 if (GMC_is_pid_bigger(fc->last_pid_sent + 1, fc->last_ack_recv) &&
4109 GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
4110 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
4111 &peer_poll,
4112 dst);
4113 } 4106 }
4107
4108 fc->queue_n++;
4109 if (GMC_is_pid_bigger(fc->last_pid_sent + 1, fc->last_ack_recv) &&
4110 GNUNET_SCHEDULER_NO_TASK == fc->poll_task)
4111 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
4112 &peer_poll,
4113 dst);
4114 queue = GNUNET_malloc (sizeof (struct MeshPeerQueue)); 4114 queue = GNUNET_malloc (sizeof (struct MeshPeerQueue));
4115 queue->cls = cls; 4115 queue->cls = cls;
4116 queue->type = type; 4116 queue->type = type;
@@ -4118,31 +4118,10 @@ queue_add (void *cls, uint16_t type, size_t size,
4118 queue->peer = dst; 4118 queue->peer = dst;
4119 queue->c = c; 4119 queue->c = c;
4120 queue->ch = ch; 4120 queue->ch = ch;
4121 if (GNUNET_YES == priority) 4121 if (100 <= priority)
4122 { 4122 GNUNET_CONTAINER_DLL_insert (fc->queue_head, fc->queue_tail, queue);
4123 struct GNUNET_MESH_Data *d;
4124 uint32_t prev;
4125 uint32_t next;
4126
4127 GNUNET_CONTAINER_DLL_insert (dst->fc->queue_head,
4128 dst->fc->queue_tail,
4129 queue);
4130 d = (struct GNUNET_MESH_Data *) queue->cls;
4131 prev = d->pid;
4132 for (queue = dst->fc->queue_tail; NULL != queue; queue = queue->prev)
4133 {
4134 if (queue->type != type)
4135 continue;
4136 d = (struct GNUNET_MESH_Data *) queue->cls;
4137 next = d->pid;
4138 d->pid = prev;
4139 prev = next;
4140 }
4141 }
4142 else 4123 else
4143 GNUNET_CONTAINER_DLL_insert_tail (dst->fc->queue_head, 4124 GNUNET_CONTAINER_DLL_insert_tail (fc->queue_head, fc->queue_tail, queue);
4144 dst->fc->queue_tail,
4145 queue);
4146 4125
4147 if (NULL == dst->fc->core_transmit) 4126 if (NULL == dst->fc->core_transmit)
4148 { 4127 {