From 16fca262be5a6769ec425ab9d97e330f9c46fce2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 12 Apr 2012 19:13:04 +0200 Subject: [PATCH] net: honor 'enable' flag in .setNoDelay() Fixes #3096. --- lib/net.js | 5 +++-- src/tcp_wrap.cc | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/net.js b/lib/net.js index af74ae1..df29bd2 100644 --- a/lib/net.js +++ b/lib/net.js @@ -183,9 +183,10 @@ Socket.prototype._onTimeout = function() { }; -Socket.prototype.setNoDelay = function() { +Socket.prototype.setNoDelay = function(enable) { + // backwards compatibility: assume true when `enable` is omitted if (this._handle && this._handle.setNoDelay) - this._handle.setNoDelay(); + this._handle.setNoDelay(typeof enable === 'undefined' ? true : !!enable); }; diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index 2e84f37..79535e1 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -253,7 +253,8 @@ Handle TCPWrap::SetNoDelay(const Arguments& args) { UNWRAP - int r = uv_tcp_nodelay(&wrap->handle_, 1); + int enable = static_cast(args[0]->BooleanValue()); + int r = uv_tcp_nodelay(&wrap->handle_, enable); if (r) SetErrno(uv_last_error(uv_default_loop())); -- 2.7.4