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

Commit

Permalink
net: honor 'enable' flag in .setNoDelay()
Browse files Browse the repository at this point in the history
Fixes #3096.
  • Loading branch information
bnoordhuis committed Apr 12, 2012
1 parent 5b43c63 commit 16fca26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/net.js
Expand Up @@ -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);
};


Expand Down
3 changes: 2 additions & 1 deletion src/tcp_wrap.cc
Expand Up @@ -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()));

Expand Down

0 comments on commit 16fca26

Please sign in to comment.