From 99c9d19184fdd46ae88464d7a608aac57a530634 Mon Sep 17 00:00:00 2001 From: Igor Zinkovsky Date: Thu, 1 Dec 2011 13:24:28 -0800 Subject: [PATCH] binding for uv_pipe_pending_instances --- lib/net.js | 15 +++++++++++++-- src/pipe_wrap.cc | 19 +++++++++++++++++++ src/pipe_wrap.h | 4 ++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/net.js b/lib/net.js index c11189ee5d..b06a78d255 100644 --- a/lib/net.js +++ b/lib/net.js @@ -657,8 +657,19 @@ var createServerHandle = exports._createServerHandle = function(address, port, addressType) { var r = 0; // assign handle in listen, and clean up if bind or listen fails - var handle = - (port == -1 && addressType == -1) ? createPipe() : createTCP(); + var handle; + + if (port == -1 && addressType == -1) { + handle = createPipe(); + if (process.platform === 'win32') { + var instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); + if (!isNaN(instances)) { + handle.setPendingInstances(instances); + } + } + } else { + handle = createTCP(); + } if (address || port) { debug('bind to ' + address); diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 0d0a004576..a2a4203a80 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -96,6 +96,10 @@ void PipeWrap::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect); NODE_SET_PROTOTYPE_METHOD(t, "open", Open); +#ifdef _WIN32 + NODE_SET_PROTOTYPE_METHOD(t, "setPendingInstances", SetPendingInstances); +#endif + pipeConstructor = Persistent::New(t->GetFunction()); target->Set(String::NewSymbol("Pipe"), pipeConstructor); @@ -142,6 +146,21 @@ Handle PipeWrap::Bind(const Arguments& args) { } +#ifdef _WIN32 +Handle PipeWrap::SetPendingInstances(const Arguments& args) { + HandleScope scope; + + UNWRAP + + int instances = args[0]->Int32Value(); + + uv_pipe_pending_instances(&wrap->handle_, instances); + + return v8::Null(); +} +#endif + + Handle PipeWrap::Listen(const Arguments& args) { HandleScope scope; diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 26a91fb962..f4c9291ae7 100644 --- a/src/pipe_wrap.h +++ b/src/pipe_wrap.h @@ -41,6 +41,10 @@ class PipeWrap : StreamWrap { static v8::Handle Connect(const v8::Arguments& args); static v8::Handle Open(const v8::Arguments& args); +#ifdef _WIN32 + static v8::Handle SetPendingInstances(const v8::Arguments& args); +#endif + static void OnConnection(uv_stream_t* handle, int status); static void AfterConnect(uv_connect_t* req, int status);