net, tls, http: remove socket.ondrain
Replace the ondrain hack with a regular 'drain' listener. Speeds up the bytes/1024 http benchmark by about 1.2%.
This commit is contained in:
parent
5988872ff1
commit
e806ad39d0
14
lib/http.js
14
lib/http.js
@ -1406,13 +1406,15 @@ exports.get = function(options, cb) {
|
|||||||
return req;
|
return req;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function ondrain() {
|
||||||
|
if (this._httpMessage) this._httpMessage.emit('drain');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function httpSocketSetup(socket) {
|
function httpSocketSetup(socket) {
|
||||||
// NOTE: be sure not to use ondrain elsewhere in this file!
|
socket.removeListener('drain', ondrain);
|
||||||
socket.ondrain = function() {
|
socket.on('drain', ondrain);
|
||||||
if (socket._httpMessage) {
|
|
||||||
socket._httpMessage.emit('drain');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -516,8 +516,6 @@ function afterWrite(status, handle, req, buffer) {
|
|||||||
self._pendingWriteReqs--;
|
self._pendingWriteReqs--;
|
||||||
|
|
||||||
if (self._pendingWriteReqs == 0) {
|
if (self._pendingWriteReqs == 0) {
|
||||||
// TODO remove all uses of ondrain - this is not a good hack.
|
|
||||||
if (self.ondrain) self.ondrain();
|
|
||||||
self.emit('drain');
|
self.emit('drain');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,9 +461,6 @@ CryptoStream.prototype._pull = function() {
|
|||||||
debug('drain ' + (this === this.pair.cleartext ? 'clear' : 'encrypted'));
|
debug('drain ' + (this === this.pair.cleartext ? 'clear' : 'encrypted'));
|
||||||
var self = this;
|
var self = this;
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
if (typeof self.ondrain === 'function') {
|
|
||||||
self.ondrain();
|
|
||||||
}
|
|
||||||
self.emit('drain');
|
self.emit('drain');
|
||||||
});
|
});
|
||||||
this._needDrain = false;
|
this._needDrain = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user