From 8adc6b89219fc6efe1d2e479288d1f02d92c6921 Mon Sep 17 00:00:00 2001 From: Henry Rawas Date: Thu, 14 Jul 2011 13:18:28 -0700 Subject: [PATCH] net_uv: Add maxConnections support --- Makefile | 1 + lib/net_uv.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 13987a4..2ae4d20 100644 --- 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 \ diff --git a/lib/net_uv.js b/lib/net_uv.js index de672b6..816529a 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -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 -- 2.7.4