Permalink
Browse files

Socket.flush: reset writeBuffer before send

This prevents legacy node versions from calling Socket.flush before it
could reset writeBuffer, leading to double-flush.
  • Loading branch information...
1 parent 5fc9785 commit bbe3d95513bc900fde15795f6733141bcae2fa22 @kapouer kapouer committed Oct 24, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/socket.js
View
@@ -293,8 +293,9 @@ Socket.prototype.flush = function () {
debug('flushing buffer to transport');
this.emit('flush', this.writeBuffer);
this.server.emit('flush', this, this.writeBuffer);
- this.transport.send(this.writeBuffer);
+ var wbuf = this.writeBuffer;
this.writeBuffer = [];
+ this.transport.send(wbuf);
this.emit('drain');
this.server.emit('drain', this);
}

0 comments on commit bbe3d95

Please sign in to comment.