From 8e159b2051510728f64f31c6b06e322cb2d7974d Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Mon, 6 Aug 2007 08:49:27 +0000 Subject: Fixed race in connection shutdown preventing Connector from being garbage collected on occasion. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@563067 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/ConnectionImpl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cpp/src/qpid/client/ConnectionImpl.cpp') diff --git a/cpp/src/qpid/client/ConnectionImpl.cpp b/cpp/src/qpid/client/ConnectionImpl.cpp index 887790e4f0..47c01f2d67 100644 --- a/cpp/src/qpid/client/ConnectionImpl.cpp +++ b/cpp/src/qpid/client/ConnectionImpl.cpp @@ -30,6 +30,7 @@ ConnectionImpl::ConnectionImpl(boost::shared_ptr c) : connector(c) handler.in = boost::bind(&ConnectionImpl::incoming, this, _1); handler.out = boost::bind(&Connector::send, connector, _1); handler.onClose = boost::bind(&ConnectionImpl::closed, this); + handler.onError = boost::bind(&ConnectionImpl::closedByPeer, this, _1, _2); connector->setInputHandler(&handler); connector->setTimeoutHandler(this); connector->setShutdownHandler(this); @@ -88,10 +89,10 @@ void ConnectionImpl::close() void ConnectionImpl::closed() { - closed(200, "OK"); + closedByPeer(200, "OK"); } -void ConnectionImpl::closed(uint16_t code, const std::string& text) +void ConnectionImpl::closedByPeer(uint16_t code, const std::string& text) { for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); i++) { i->second->closed(code, text); @@ -114,7 +115,7 @@ void ConnectionImpl::idleOut() void ConnectionImpl::shutdown() { //this indicates that the socket to the server has closed for (SessionMap::iterator i = sessions.begin(); i != sessions.end(); i++) { - i->second->closed(0, "Unexpected scoket closure."); + i->second->closed(0, "Unexpected socket closure."); } sessions.clear(); } -- cgit v1.2.1