[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35414 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35414 - gnunet/src/core |
Date: |
Sat, 21 Mar 2015 00:22:22 +0100 |
Author: grothoff
Date: 2015-03-21 00:22:22 +0100 (Sat, 21 Mar 2015)
New Revision: 35414
Modified:
gnunet/src/core/gnunet-service-core_neighbours.c
gnunet/src/core/gnunet-service-core_neighbours.h
gnunet/src/core/gnunet-service-core_sessions.c
Log:
fix #3709: bound encrypted message queue
Modified: gnunet/src/core/gnunet-service-core_neighbours.c
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.c 2015-03-20 18:14:40 UTC
(rev 35413)
+++ gnunet/src/core/gnunet-service-core_neighbours.c 2015-03-20 23:22:22 UTC
(rev 35414)
@@ -103,9 +103,14 @@
/**
* ID of task used for re-trying plaintext scheduling.
*/
- struct GNUNET_SCHEDULER_Task * retry_plaintext_task;
+ struct GNUNET_SCHEDULER_Task *retry_plaintext_task;
/**
+ * How many messages are in the queue for this neighbour?
+ */
+ unsigned int queue_size;
+
+ /**
* #GNUNET_YES if this peer currently has excess bandwidth.
*/
int has_excess_bandwidth;
@@ -155,9 +160,13 @@
GNUNET_i2s (&n->peer));
while (NULL != (m = n->message_head))
{
- GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
+ GNUNET_CONTAINER_DLL_remove (n->message_head,
+ n->message_tail,
+ m);
+ n->queue_size--;
GNUNET_free (m);
}
+ GNUNET_assert (0 == n->queue_size);
if (NULL != n->th)
{
GNUNET_TRANSPORT_notify_transmit_ready_cancel (n->th);
@@ -172,7 +181,7 @@
GSC_KX_stop (n->kxinfo);
n->kxinfo = NULL;
}
- if (n->retry_plaintext_task != NULL)
+ if (NULL != n->retry_plaintext_task)
{
GNUNET_SCHEDULER_cancel (n->retry_plaintext_task);
n->retry_plaintext_task = NULL;
@@ -223,7 +232,10 @@
GNUNET_break (0);
return 0;
}
- GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
+ GNUNET_CONTAINER_DLL_remove (n->message_head,
+ n->message_tail,
+ m);
+ n->queue_size--;
if (NULL == buf)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -297,6 +309,7 @@
GNUNET_CONTAINER_DLL_remove (n->message_head,
n->message_tail,
m);
+ n->queue_size--;
GNUNET_free (m);
process_queue (n);
}
@@ -463,6 +476,7 @@
GNUNET_CONTAINER_DLL_insert_tail (n->message_head,
n->message_tail,
me);
+ n->queue_size++;
process_queue (n);
}
@@ -495,6 +509,28 @@
/**
+ * Check how many messages are queued for the given neighbour.
+ *
+ * @param target neighbour to check
+ * @return number of items in the message queue
+ */
+unsigned int
+GSC_NEIGHBOURS_get_queue_size (const struct GNUNET_PeerIdentity *target)
+{
+ struct Neighbour *n;
+
+ n = find_neighbour (target);
+ if (NULL == n)
+ {
+ GNUNET_break (0);
+ return UINT_MAX;
+ }
+ return n->queue_size;
+}
+
+
+
+/**
* Check if the given neighbour has excess bandwidth available.
*
* @param target neighbour to check
Modified: gnunet/src/core/gnunet-service-core_neighbours.h
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.h 2015-03-20 18:14:40 UTC
(rev 35413)
+++ gnunet/src/core/gnunet-service-core_neighbours.h 2015-03-20 23:22:22 UTC
(rev 35414)
@@ -57,6 +57,16 @@
/**
+ * Check how many messages are queued for the given neighbour.
+ *
+ * @param target neighbour to check
+ * @return number of items in the message queue
+ */
+unsigned int
+GSC_NEIGHBOURS_get_queue_size (const struct GNUNET_PeerIdentity *target);
+
+
+/**
* Initialize neighbours subsystem.
*/
int
Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c 2015-03-20 18:14:40 UTC
(rev 35413)
+++ gnunet/src/core/gnunet-service-core_sessions.c 2015-03-20 23:22:22 UTC
(rev 35414)
@@ -35,6 +35,13 @@
/**
+ * How many encrypted messages do we queue at most?
+ * Needed to bound memory consumption.
+ */
+#define MAX_ENCRYPTED_MESSAGE_QUEUE_SIZE 4
+
+
+/**
* Message ready for encryption. This struct is followed by the
* actual content of the message.
*/
@@ -639,6 +646,9 @@
min_deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
/* if the peer has excess bandwidth, background traffic is allowed,
otherwise not */
+ if (MAX_ENCRYPTED_MESSAGE_QUEUE_SIZE >=
+ GSC_NEIGHBOURS_check_excess_bandwidth (&session->peer))
+ return; /* queue already too long */
excess = GSC_NEIGHBOURS_check_excess_bandwidth (&session->peer);
if (GNUNET_YES == excess)
maxp = GNUNET_CORE_PRIO_BACKGROUND;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35414 - gnunet/src/core,
gnunet <=