Fix GH-819. Drop out if connection destroyed before connect()
authorRyan Dahl <ry@tinyclouds.org>
Mon, 21 Mar 2011 21:48:26 +0000 (14:48 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Mon, 21 Mar 2011 21:48:26 +0000 (14:48 -0700)
lib/net.js
test/simple/test-regress-GH-819.js [new file with mode: 0644]

index 39010bf8b1577d7afbb9a3a3e3bee17a5fbecb9b..1be0e49db968ad44b6231aa5f6497e865ae6cf3e 100644 (file)
@@ -547,6 +547,8 @@ Socket.prototype.setEncoding = function(encoding) {
 
 
 function doConnect(socket, port, host) {
+  if (socket.destroyed) return;
+
   timers.active(socket);
 
   try {
diff --git a/test/simple/test-regress-GH-819.js b/test/simple/test-regress-GH-819.js
new file mode 100644 (file)
index 0000000..50e037b
--- /dev/null
@@ -0,0 +1,7 @@
+var common = require('../common');
+var net = require('net');
+var assert = require('assert');
+
+// Connect to something that we need to DNS resolve
+var c = net.createConnection(80, "google.com");
+c.destroy();