From 62c4214711f1ac16c8ad4fe3f5fb9abc5e6b15c4 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 2 Mar 2010 20:59:25 +0000 Subject: [PATCH] Properly throw error on failed connection --- src/node_net.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/node_net.cc b/src/node_net.cc index da43517f11..b9f739c0e5 100644 --- a/src/node_net.cc +++ b/src/node_net.cc @@ -337,7 +337,7 @@ int Connection::AfterResolve(eio_req *req) { if (address_list) freeaddrinfo(address_list); // no error. return. - if (req->result == 0) { + if (req->result == 0 && !r) { evcom_stream_attach(EV_DEFAULT_UC_ &connection->stream_); goto out; } @@ -348,7 +348,13 @@ int Connection::AfterResolve(eio_req *req) { * The fact that I'm modifying a read-only variable here should be * good evidence of this. */ - connection->stream_.errorno = req->result; + + if (req->result) { + connection->stream_.errorno = req->result; + } else { + assert(r); + assert(connection->stream_.errorno); + } connection->OnClose();