windows: enable pending accepts knob
This commit is contained in:
parent
21b64dc7c9
commit
3060266ff1
@ -69,11 +69,29 @@ function mergeOptions(target, overrides) {
|
|||||||
|
|
||||||
|
|
||||||
function setupChannel(target, channel) {
|
function setupChannel(target, channel) {
|
||||||
|
var isWindows = process.platform === 'win32';
|
||||||
target._channel = channel;
|
target._channel = channel;
|
||||||
|
|
||||||
var jsonBuffer = '';
|
var jsonBuffer = '';
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
var setSimultaneousAccepts = function(handle) {
|
||||||
|
var simultaneousAccepts = (process.env.NODE_MANY_ACCEPTS
|
||||||
|
&& process.env.NODE_MANY_ACCEPTS != '0') ? true : false;
|
||||||
|
|
||||||
|
if (handle._simultaneousAccepts != simultaneousAccepts) {
|
||||||
|
handle.setSimultaneousAccepts(simultaneousAccepts);
|
||||||
|
handle._simultaneousAccepts = simultaneousAccepts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
channel.onread = function(pool, offset, length, recvHandle) {
|
channel.onread = function(pool, offset, length, recvHandle) {
|
||||||
|
if (recvHandle && setSimultaneousAccepts) {
|
||||||
|
// Update simultaneous accepts on Windows
|
||||||
|
setSimultaneousAccepts(recvHandle);
|
||||||
|
}
|
||||||
|
|
||||||
if (pool) {
|
if (pool) {
|
||||||
jsonBuffer += pool.toString('ascii', offset, offset + length);
|
jsonBuffer += pool.toString('ascii', offset, offset + length);
|
||||||
|
|
||||||
@ -103,6 +121,11 @@ function setupChannel(target, channel) {
|
|||||||
|
|
||||||
var buffer = Buffer(JSON.stringify(message) + '\n');
|
var buffer = Buffer(JSON.stringify(message) + '\n');
|
||||||
|
|
||||||
|
if (sendHandle && setSimultaneousAccepts) {
|
||||||
|
// Update simultaneous accepts on Windows
|
||||||
|
setSimultaneousAccepts(sendHandle);
|
||||||
|
}
|
||||||
|
|
||||||
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle);
|
var writeReq = channel.write(buffer, 0, buffer.length, sendHandle);
|
||||||
|
|
||||||
if (!writeReq) {
|
if (!writeReq) {
|
||||||
|
@ -100,6 +100,10 @@ void TCPWrap::Initialize(Handle<Object> target) {
|
|||||||
NODE_SET_PROTOTYPE_METHOD(t, "setNoDelay", SetNoDelay);
|
NODE_SET_PROTOTYPE_METHOD(t, "setNoDelay", SetNoDelay);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "setKeepAlive", SetKeepAlive);
|
NODE_SET_PROTOTYPE_METHOD(t, "setKeepAlive", SetKeepAlive);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
NODE_SET_PROTOTYPE_METHOD(t, "setSimultaneousAccepts", SetSimultaneousAccepts);
|
||||||
|
#endif
|
||||||
|
|
||||||
tcpConstructor = Persistent<Function>::New(t->GetFunction());
|
tcpConstructor = Persistent<Function>::New(t->GetFunction());
|
||||||
|
|
||||||
family_symbol = NODE_PSYMBOL("family");
|
family_symbol = NODE_PSYMBOL("family");
|
||||||
@ -251,6 +255,23 @@ Handle<Value> TCPWrap::SetKeepAlive(const Arguments& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
Handle<Value> TCPWrap::SetSimultaneousAccepts(const Arguments& args) {
|
||||||
|
HandleScope scope;
|
||||||
|
|
||||||
|
UNWRAP
|
||||||
|
|
||||||
|
bool enable = args[0]->BooleanValue();
|
||||||
|
|
||||||
|
int r = uv_tcp_simultaneous_accepts(&wrap->handle_, enable ? 1 : 0);
|
||||||
|
if (r)
|
||||||
|
SetErrno(uv_last_error(uv_default_loop()));
|
||||||
|
|
||||||
|
return Undefined();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Handle<Value> TCPWrap::Bind(const Arguments& args) {
|
Handle<Value> TCPWrap::Bind(const Arguments& args) {
|
||||||
HandleScope scope;
|
HandleScope scope;
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@ class TCPWrap : public StreamWrap {
|
|||||||
static v8::Handle<v8::Value> Connect6(const v8::Arguments& args);
|
static v8::Handle<v8::Value> Connect6(const v8::Arguments& args);
|
||||||
static v8::Handle<v8::Value> Open(const v8::Arguments& args);
|
static v8::Handle<v8::Value> Open(const v8::Arguments& args);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static v8::Handle<v8::Value> SetSimultaneousAccepts(const v8::Arguments& args);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void OnConnection(uv_stream_t* handle, int status);
|
static void OnConnection(uv_stream_t* handle, int status);
|
||||||
static void AfterConnect(uv_connect_t* req, int status);
|
static void AfterConnect(uv_connect_t* req, int status);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user