From d7a86ff05ec25951a14d232b6c19e9d41c0a3541 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 21 Mar 2011 14:48:26 -0700 Subject: [PATCH] Fix GH-819. Drop out if connection destroyed before connect() --- lib/net.js | 2 ++ test/simple/test-regress-GH-819.js | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 test/simple/test-regress-GH-819.js diff --git a/lib/net.js b/lib/net.js index 39010bf8b1..1be0e49db9 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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 index 0000000000..50e037b461 --- /dev/null +++ b/test/simple/test-regress-GH-819.js @@ -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();