prevent buffered _writes from binding thousands of events.
This commit is contained in:
parent
a96f27682f
commit
cb2bcc21c6
@ -244,13 +244,24 @@ Peer.prototype.destroy = function destroy() {
|
||||
// Private APIs
|
||||
|
||||
Peer.prototype._write = function write(chunk) {
|
||||
var self = this;
|
||||
|
||||
if (this.destroyed)
|
||||
return;
|
||||
|
||||
if (!this.socket) {
|
||||
return this.once('socket', function() {
|
||||
this._write(chunk);
|
||||
});
|
||||
if (!this._bchunks) {
|
||||
this._bchunks = [];
|
||||
this.once('socket', function() {
|
||||
var chunks = self._bchunks;
|
||||
delete self._bchunks;
|
||||
chunks.forEach(function(chunk) {
|
||||
self._write(chunk);
|
||||
});
|
||||
});
|
||||
}
|
||||
this._bchunks.push(chunk);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NodeBuffer)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user