From 5f5201db2ffaeb773f32e747d268307089156148 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 12 Jan 2011 13:29:43 -0800 Subject: [PATCH] Fix test-net-connect-buffer Change to end() behavior in 33c339 was breaking it. end() should wait for connection before dumping. Changed test-net-connect-timeout to use destroy() instead. --- lib/net.js | 4 +--- test/simple/test-net-connect-timeout.js | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/net.js b/lib/net.js index e78bb1e150..6eed683b9b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -787,9 +787,7 @@ Socket.prototype._shutdown = function() { Socket.prototype.end = function(data, encoding) { - if (this._connecting) { - this.destroy(); - } else if (this.writable) { + if (this.writable) { if (this._writeQueueLast() !== END_OF_FILE) { if (data) this.write(data, encoding); this._writeQueue.push(END_OF_FILE); diff --git a/test/simple/test-net-connect-timeout.js b/test/simple/test-net-connect-timeout.js index 59d7cfa55c..ad7dfa92ae 100644 --- a/test/simple/test-net-connect-timeout.js +++ b/test/simple/test-net-connect-timeout.js @@ -30,13 +30,13 @@ socket0.on('timeout', function() { gotTimeout0 = true; var now = new Date(); assert.ok(now - start < T + 500); - socket0.end(); + socket0.destroy(); }); socket0.on('connect', function() { console.error("connect"); gotConnect0 = true; - socket0.end(); + socket0.destroy(); }); @@ -51,13 +51,13 @@ socket1.on('timeout', function() { gotTimeout1 = true; var now = new Date(); assert.ok(now - start < T + 500); - socket1.end(); + socket1.destroy(); }); socket1.on('connect', function() { console.error("connect"); gotConnect1 = true; - socket1.end(); + socket1.destroy(); });