You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2019/03/25 21:03:45 UTC

[qpid-cpp] 02/03: QPID-8288: ensure closed is notified without waiting for deletion of connection

This is an automated email from the ASF dual-hosted git repository.

gsim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-cpp.git

commit 8ed016c6bba566e257d72ae3938b4cab34e8778f
Author: Gordon Sim <gs...@redhat.com>
AuthorDate: Tue Mar 19 14:06:59 2019 +0000

    QPID-8288: ensure closed is notified without waiting for deletion of connection
---
 src/qpid/broker/amqp_0_10/Connection.cpp | 10 +++++++++-
 src/qpid/broker/amqp_0_10/Connection.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/qpid/broker/amqp_0_10/Connection.cpp b/src/qpid/broker/amqp_0_10/Connection.cpp
index 4682c1f..7d335c9 100644
--- a/src/qpid/broker/amqp_0_10/Connection.cpp
+++ b/src/qpid/broker/amqp_0_10/Connection.cpp
@@ -139,6 +139,7 @@ Connection::Connection(ConnectionOutputHandler* out_,
     heartbeat(0),
     heartbeatmax(120),
     isDefaultRealm(false),
+    hasSignalledClosed(false),
     securitySettings(external),
     link(link_),
     adapter(*this, link),
@@ -180,7 +181,10 @@ Connection::~Connection()
             << " rhost:" << mgmtId );
         mgmtObject->resourceDestroy();
     }
-    broker.getConnectionObservers().closed(*this);
+    if (!hasSignalledClosed) {
+        broker.getConnectionObservers().closed(*this);
+        hasSignalledClosed = true;
+    }
 
     if (heartbeatTimer)
         heartbeatTimer->cancel();
@@ -376,6 +380,10 @@ void Connection::closed(){ // Physically closed, suspend open sessions.
         QPID_LOG(error, QPID_MSG("While closing connection: " << e.what()));
         assert(0);
     }
+    if (!hasSignalledClosed) {
+        broker.getConnectionObservers().closed(*this);
+        hasSignalledClosed = true;
+    }
 }
 
 void Connection::doIoCallbacks() {
diff --git a/src/qpid/broker/amqp_0_10/Connection.h b/src/qpid/broker/amqp_0_10/Connection.h
index 8fff520..719683d 100644
--- a/src/qpid/broker/amqp_0_10/Connection.h
+++ b/src/qpid/broker/amqp_0_10/Connection.h
@@ -196,6 +196,7 @@ class Connection : public sys::ConnectionInputHandler, public qpid::broker::Conn
     std::vector<Url> knownHosts;
     std::string userName;
     bool isDefaultRealm;
+    bool hasSignalledClosed;
 
     typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org