From 5d6a03c9fe562b80ecb6ae2b3fc34798a1235e7d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 12 Nov 2010 11:47:31 -0800 Subject: [PATCH] Don't append buckets of zero length --- lib/net.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/net.js b/lib/net.js index 12db1f45e58..a25673c3a04 100644 --- a/lib/net.js +++ b/lib/net.js @@ -249,21 +249,23 @@ Object.defineProperty(Stream.prototype, 'readyState', { Stream.prototype._appendBucket = function (data, encoding, fd) { - // TODO reject empty data. - var newBucket = { data: data }; - if (encoding) newBucket.encoding = encoding; - if (fd) newBucket.fd = fd; + if (data.length != 0) { + // TODO reject empty data. + var newBucket = { data: data }; + if (encoding) newBucket.encoding = encoding; + if (fd) newBucket.fd = fd; - // TODO properly calculate queueSize + // TODO properly calculate queueSize - if (this._writeWatcher.lastBucket) { - this._writeWatcher.lastBucket.next = newBucket; - } else { - this._writeWatcher.firstBucket = newBucket; + if (this._writeWatcher.lastBucket) { + this._writeWatcher.lastBucket.next = newBucket; + } else { + this._writeWatcher.firstBucket = newBucket; + } + + this._writeWatcher.lastBucket = newBucket; } - this._writeWatcher.lastBucket = newBucket; - if (this._writeWatcher.queueSize === undefined) { this._writeWatcher.queueSize = 0; }