From 94d664ca0e70489a38d6791b2768babc10f222e5 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 22 Aug 2011 21:54:00 +0000 Subject: QPID-3447: Creating invalid federation link causes file descriptor leak - Previously we weren't correctly handling synchronous errors when we attempted to connect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1160458 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/TCPIOPlugin.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index c5cc86c813..85d8c1db87 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -164,6 +164,7 @@ void AsynchIOProtocolFactory::connect( // shutdown. The allocated AsynchConnector frees itself when it // is no longer needed. Socket* socket = new Socket(); + try { AsynchConnector* c = AsynchConnector::create( *socket, host, @@ -173,6 +174,12 @@ void AsynchIOProtocolFactory::connect( boost::bind(&AsynchIOProtocolFactory::connectFailed, this, _1, _2, _3, failed)); c->start(poller); + } catch (std::exception&) { + // TODO: Design question - should we do the error callback and also throw? + int errCode = socket->getError(); + connectFailed(*socket, errCode, strError(errCode), failed); + throw; + } } }} // namespace qpid::sys -- cgit v1.2.1