summaryrefslogtreecommitdiffstats
path: root/polyp/protocol-simple.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-11-18 00:28:26 +0000
committerLennart Poettering <lennart@poettering.net>2004-11-18 00:28:26 +0000
commiteef235d8795df740eb63cb135bd187b7ab9ac4ea (patch)
tree0667fdeb1ed052004a6375a175e35dd06ada3476 /polyp/protocol-simple.c
parentc57d5deef6ee33ab892398c7fd27400cd4ce4542 (diff)
limit the number of concurrent connections for all four protocols
kick a client if it doesn't authenticate within 5s on ESD and native protocol git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@292 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/protocol-simple.c')
-rw-r--r--polyp/protocol-simple.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/polyp/protocol-simple.c b/polyp/protocol-simple.c
index f7c69d6b..058d4b82 100644
--- a/polyp/protocol-simple.c
+++ b/polyp/protocol-simple.c
@@ -39,6 +39,9 @@
#include "xmalloc.h"
#include "log.h"
+/* Don't allow more than this many concurrent connections */
+#define MAX_CONNECTIONS 10
+
struct connection {
struct pa_protocol_simple *protocol;
struct pa_iochannel *io;
@@ -287,6 +290,12 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
char cname[256];
assert(s && io && p);
+ if (pa_idxset_ncontents(p->connections)+1 > MAX_CONNECTIONS) {
+ pa_log(__FILE__": Warning! Too many connections (%u), dropping incoming connection.\n", MAX_CONNECTIONS);
+ pa_iochannel_free(io);
+ return;
+ }
+
c = pa_xmalloc(sizeof(struct connection));
c->io = io;
c->sink_input = NULL;