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(); });