Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
binding for uv_pipe_pending_instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Dec 1, 2011
1 parent dd4b280 commit 99c9d19
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/net.js
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions src/pipe_wrap.cc
Expand Up @@ -96,6 +96,10 @@ void PipeWrap::Initialize(Handle<Object> 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<Function>::New(t->GetFunction());

target->Set(String::NewSymbol("Pipe"), pipeConstructor);
Expand Down Expand Up @@ -142,6 +146,21 @@ Handle<Value> PipeWrap::Bind(const Arguments& args) {
}


#ifdef _WIN32
Handle<Value> 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<Value> PipeWrap::Listen(const Arguments& args) {
HandleScope scope;

Expand Down
4 changes: 4 additions & 0 deletions src/pipe_wrap.h
Expand Up @@ -41,6 +41,10 @@ class PipeWrap : StreamWrap {
static v8::Handle<v8::Value> Connect(const v8::Arguments& args);
static v8::Handle<v8::Value> Open(const v8::Arguments& args);

#ifdef _WIN32
static v8::Handle<v8::Value> SetPendingInstances(const v8::Arguments& args);
#endif

static void OnConnection(uv_stream_t* handle, int status);
static void AfterConnect(uv_connect_t* req, int status);

Expand Down

0 comments on commit 99c9d19

Please sign in to comment.