Skip to content

Commit

Permalink
fix: socket.destroyed always be undefined on 0.10.x
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Apr 1, 2015
1 parent d2cbc1e commit ac81e8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (node10) {
}
};
} else {
debug = util.debuglog('http');
debug = util.debuglog('agentkeepalive');
}

// New Agent code.
Expand Down Expand Up @@ -233,6 +233,11 @@ Agent.prototype.createSocket = function(req, options) {

function onClose(err) {
debug('CLIENT socket onClose');
// fix: socket.destroyed always be undefined on 0.10.x
if (typeof s.destroyed !== 'boolean') {
s.destroyed = true;
}

// This is the only place where sockets get removed from the Agent.
// If you want to remove a socket from the pool, just close it.
// All socket errors end in a close event anyway.
Expand Down
4 changes: 2 additions & 2 deletions lib/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (node10) {
}
};
} else {
debug = util.debuglog('http');
debug = util.debuglog('agentkeepalive');
}

module.exports = Agent;
Expand Down Expand Up @@ -76,7 +76,7 @@ Agent.prototype.createSocket = function (req, options) {
var socket = OriginalAgent.prototype.createSocket.call(this, req, options);
if (this.keepAlive) {
// Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/
// http://fengmk2.cnpmjs.org/benchmark/nagle-algorithm-delayed-ack-mock.html
// http://fengmk2.com/benchmark/nagle-algorithm-delayed-ack-mock.html
socket.setNoDelay(true);
}
this.createSocketCount++;
Expand Down

0 comments on commit ac81e8e

Please sign in to comment.