Commit
Replace the ondrain hack with a regular 'drain' listener. Speeds up the bytes/1024 http benchmark by about 1.2%.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1406,13 +1406,15 @@ exports.get = function(options, cb) { | |
return req; | ||
}; | ||
|
||
|
||
function ondrain() { | ||
if (this._httpMessage) this._httpMessage.emit('drain'); | ||
} | ||
|
||
|
||
function httpSocketSetup(socket) { | ||
// NOTE: be sure not to use ondrain elsewhere in this file! | ||
socket.ondrain = function() { | ||
if (socket._httpMessage) { | ||
socket._httpMessage.emit('drain'); | ||
} | ||
}; | ||
socket.removeListener('drain', ondrain); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bnoordhuis
Author
Member
|
||
socket.on('drain', ondrain); | ||
} | ||
|
||
|
||
|
@bnoordhuis The function 'ondrain' refers the same as the one added in the next line. It seems the same listener to be removed and added. If this line is intended to cleanup all drain listeners previously added elsewhere, is e40b07e right way to do it?