Skip to content

Commit

Permalink
Socket.flush: reset writeBuffer before send
Browse files Browse the repository at this point in the history
This prevents legacy node versions from calling Socket.flush before it
could reset writeBuffer, leading to double-flush.
  • Loading branch information
kapouer committed Oct 24, 2012
1 parent 5fc9785 commit bbe3d95
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/socket.js
Expand Up @@ -293,8 +293,9 @@ Socket.prototype.flush = function () {
debug('flushing buffer to transport'); debug('flushing buffer to transport');
this.emit('flush', this.writeBuffer); this.emit('flush', this.writeBuffer);
this.server.emit('flush', this, this.writeBuffer); this.server.emit('flush', this, this.writeBuffer);
this.transport.send(this.writeBuffer); var wbuf = this.writeBuffer;
this.writeBuffer = []; this.writeBuffer = [];
this.transport.send(wbuf);
this.emit('drain'); this.emit('drain');
this.server.emit('drain', this); this.server.emit('drain', this);
} }
Expand Down

0 comments on commit bbe3d95

Please sign in to comment.