[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25146 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25146 - gnunet/src/fs |
Date: |
Wed, 28 Nov 2012 13:25:37 +0100 |
Author: grothoff
Date: 2012-11-28 13:25:37 +0100 (Wed, 28 Nov 2012)
New Revision: 25146
Modified:
gnunet/src/fs/fs.conf.in
gnunet/src/fs/gnunet-service-fs_stream.c
Log:
-implementing limit to number of stream client connections
Modified: gnunet/src/fs/fs.conf.in
===================================================================
--- gnunet/src/fs/fs.conf.in 2012-11-27 21:09:27 UTC (rev 25145)
+++ gnunet/src/fs/fs.conf.in 2012-11-28 12:25:37 UTC (rev 25146)
@@ -54,7 +54,15 @@
# This option is mostly for testing.
DISABLE_ANON_TRANSFER = NO
+# Maximum number of non-anonymous transfers this peer will support
+# at the same time. Excessive values mostly have the problem that
+# the service might use more memory, so we need to bound this at
+# some reasonable level. And if we have a very, very large
+# number, we probably won't have enough bandwidth to suppor them
+# well anyway, so better have a moderate cap.
+MAX_STREAM_CLIENTS = 128
+
[gnunet-auto-share]
BINARY = gnunet-auto-share
Modified: gnunet/src/fs/gnunet-service-fs_stream.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_stream.c 2012-11-27 21:09:27 UTC (rev
25145)
+++ gnunet/src/fs/gnunet-service-fs_stream.c 2012-11-28 12:25:37 UTC (rev
25146)
@@ -22,9 +22,6 @@
* @file fs/gnunet-service-fs_stream.c
* @brief non-anonymous file-transfer
* @author Christian Grothoff
- *
- * TODO:
- * - limit # concurrent clients
*/
#include "platform.h"
#include "gnunet_constants.h"
@@ -289,6 +286,16 @@
static struct StreamClient *sc_tail;
/**
+ * Number of active stream clients in the 'sc_*'-DLL.
+ */
+static unsigned int sc_count;
+
+/**
+ * Maximum allowed number of stream clients.
+ */
+static unsigned long long sc_count_max;
+
+/**
* Map from peer identities to 'struct StreamHandles' with streams to
* those peers.
*/
@@ -885,6 +892,7 @@
GNUNET_CONTAINER_DLL_remove (sc_head,
sc_tail,
sc);
+ sc_count--;
GNUNET_free (sc);
}
@@ -1237,6 +1245,13 @@
if (NULL == socket)
return GNUNET_SYSERR;
+ if (sc_count >= sc_count_max)
+ {
+ GNUNET_STATISTICS_update (GSF_stats,
+ gettext_noop ("# stream client connections
rejected"), 1,
+ GNUNET_NO);
+ return GNUNET_SYSERR;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Accepting inbound stream connection from `%s'\n",
GNUNET_i2s (initiator));
@@ -1254,6 +1269,7 @@
GNUNET_CONTAINER_DLL_insert (sc_head,
sc_tail,
sc);
+ sc_count++;
refresh_timeout_task (sc);
return GNUNET_OK;
}
@@ -1266,10 +1282,17 @@
GSF_stream_start ()
{
stream_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
- listen_socket = GNUNET_STREAM_listen (GSF_cfg,
-
GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER,
- &accept_cb, NULL,
- GNUNET_STREAM_OPTION_END);
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_number (GSF_cfg,
+ "fs",
+ "MAX_STREAM_CLIENTS",
+ &sc_count_max))
+ {
+ listen_socket = GNUNET_STREAM_listen (GSF_cfg,
+
GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER,
+ &accept_cb, NULL,
+ GNUNET_STREAM_OPTION_END);
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25146 - gnunet/src/fs,
gnunet <=