net_uv: Add maxConnections support
authorHenry Rawas <henryr@schakra.com>
Thu, 14 Jul 2011 20:18:28 +0000 (13:18 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 14 Jul 2011 20:23:08 +0000 (13:23 -0700)
Makefile
lib/net_uv.js

index 13987a4..2ae4d20 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -139,6 +139,7 @@ test-uv: all
                simple/test-net-pingpong \
                simple/test-net-reconnect \
                simple/test-net-remote-address-port \
+               simple/test-net-server-max-connections \
                simple/test-net-server-try-ports \
                simple/test-net-stream \
                simple/test-net-socket-timeout \
index de672b6..816529a 100644 (file)
@@ -538,6 +538,11 @@ function onconnection(clientHandle) {
 
   debug("onconnection");
 
+  if (self.maxConnections && self.connections >= self.maxConnections) {
+    clientHandle.close();
+    return;
+  }
+
   var socket = new Socket({
     handle: clientHandle,
     allowHalfOpen: self.allowHalfOpen