[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8514 - gnunet/src/core
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8514 - gnunet/src/core |
Date: |
Tue, 9 Jun 2009 20:44:49 -0600 |
Author: grothoff
Date: 2009-06-09 20:44:49 -0600 (Tue, 09 Jun 2009)
New Revision: 8514
Modified:
gnunet/src/core/gnunet-service-core.c
Log:
bound client queue size
Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c 2009-06-10 02:37:46 UTC (rev
8513)
+++ gnunet/src/core/gnunet-service-core.c 2009-06-10 02:44:49 UTC (rev
8514)
@@ -23,10 +23,8 @@
* @brief high-level P2P messaging
* @author Christian Grothoff
*
- * TODO:
* POST-TESTING:
* - revisit API (which arguments are used, needed)?
- * - add code to bound message queue size when passing messages to clients
* - add code to re-transmit key if first attempt failed
* + timeout on connect / key exchange, etc.
* + timeout for automatic re-try, etc.
@@ -40,7 +38,6 @@
* know for sure!
* - check that hostkey used by transport (for HELLOs) is the
* same as the hostkey that we are using!
- * - free list of clients on exit
* - topology management:
* + bootstrapping (transport offer hello, plugins)
* + internal neighbour selection
@@ -134,6 +131,12 @@
/**
+ * How many non-mandatory messages do we queue per client at most?
+ */
+#define MAX_CLIENT_QUEUE_SIZE 32
+
+
+/**
* What is the maximum age of a message for us to consider
* processing it? Note that this looks at the timestamp used
* by the other peer, so clock skew between machines does
@@ -723,6 +726,7 @@
/**
* Client is ready to receive data, provide it.
+ *
* @param cls closure
* @param size number of bytes available in buf
* @param buf where the callee should write the message
@@ -809,6 +813,7 @@
const struct GNUNET_MessageHeader *msg, int can_drop)
{
struct Event *e;
+ unsigned int queue_size;
uint16_t msize;
#if DEBUG_CORE_CLIENT
@@ -816,6 +821,17 @@
"Preparing to send message of type %u to client.\n",
ntohs (msg->type));
#endif
+ queue_size = 0;
+ e = client->event_head;
+ while (e != NULL)
+ {
+ queue_size++;
+ e = e->next;
+ }
+ if ( (queue_size >= MAX_CLIENT_QUEUE_SIZE) &&
+ (can_drop == GNUNET_YES) )
+ return;
+
msize = ntohs (msg->size);
e = GNUNET_malloc (sizeof (struct Event) + msize);
/* append */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8514 - gnunet/src/core,
gnunet <=