From 71dc232f93a394daf9a372f6ef14c1458f38f534 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 13 Apr 2010 15:56:06 -0700 Subject: [PATCH] Use === instead of == for END_OF_FILE compares This caused a very hard to track down bug. Thanks to Mikeal Rogers for this fix. Unfortunately we were unable to put together a test case. --- lib/net.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/net.js b/lib/net.js index 72eb878c8e..d906211238 100644 --- a/lib/net.js +++ b/lib/net.js @@ -382,7 +382,7 @@ Object.defineProperty(Stream.prototype, 'readyState', { Stream.prototype.write = function (data, encoding) { if (this._writeQueue && this._writeQueue.length) { // Slow. There is already a write queue, so let's append to it. - if (this._writeQueueLast() == END_OF_FILE) { + if (this._writeQueueLast() === END_OF_FILE) { throw new Error('Stream.close() called already; cannot write.'); } this._writeQueue.push(data); // TODO if string of the same encoding concat? @@ -511,7 +511,7 @@ Stream.prototype.flush = function () { var data = this._writeQueue.shift(); var encoding = this._writeQueueEncoding.shift(); - if (data == END_OF_FILE) { + if (data === END_OF_FILE) { this._shutdown(); return true; } @@ -714,7 +714,7 @@ Stream.prototype.close = function (data, encoding) { Stream.prototype.end = function (data, encoding) { if (this.writable) { if (data) this.write(data, encoding); - if (this._writeQueueLast() != END_OF_FILE) { + if (this._writeQueueLast() !== END_OF_FILE) { this._writeQueue.push(END_OF_FILE); this.flush(); }