Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

net: honor 'enable' flag in .setNoDelay()

Fixes #3096.
  • Loading branch information...
commit 16fca262be5a6769ec425ab9d97e330f9c46fce2 1 parent 5b43c63
Ben Noordhuis bnoordhuis authored
Showing with 5 additions and 3 deletions.
  1. +3 −2 lib/net.js
  2. +2 −1  src/tcp_wrap.cc
5 lib/net.js
View
@@ -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);
};
3  src/tcp_wrap.cc
View
@@ -253,7 +253,8 @@ Handle<Value> TCPWrap::SetNoDelay(const Arguments& args) {
UNWRAP
- int r = uv_tcp_nodelay(&wrap->handle_, 1);
+ int enable = static_cast<int>(args[0]->BooleanValue());
+ int r = uv_tcp_nodelay(&wrap->handle_, enable);
if (r)
SetErrno(uv_last_error(uv_default_loop()));
Please sign in to comment.
Something went wrong with that request. Please try again.