From 02039c9b53811cbce3b324c655f9bdfc7504813f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 17 Nov 2010 11:50:51 -0800 Subject: [PATCH] 'connect' event may disconnect socket --- lib/net.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/net.js b/lib/net.js index 7019d9d107..6d0aef9ca8 100644 --- a/lib/net.js +++ b/lib/net.js @@ -367,6 +367,12 @@ Stream.prototype._onConnect = function () { this._connecting = false; this.resume(); this.readable = this.writable = true; + + if (this._writeWatcher.firstBucket) { + // Flush this in case any writes are queued up while connecting. + this._onWritable(); + } + try { this.emit('connect'); } catch (e) { @@ -374,12 +380,6 @@ Stream.prototype._onConnect = function () { return; } - - if (this._writeWatcher.firstBucket) { - // Flush this in case any writes are queued up while connecting. - this._onWritable(); - } - } else if (errno != EINPROGRESS) { this.destroy(errnoException(errno, 'connect')); }