diff options
-rw-r--r-- | cpp/src/qpid/broker/Connection.cpp | 6 | ||||
-rw-r--r-- | python/tests_0-10/management.py | 22 |
2 files changed, 26 insertions, 2 deletions
diff --git a/cpp/src/qpid/broker/Connection.cpp b/cpp/src/qpid/broker/Connection.cpp index a1a3c6ada7..3b8a6c71d4 100644 --- a/cpp/src/qpid/broker/Connection.cpp +++ b/cpp/src/qpid/broker/Connection.cpp @@ -269,11 +269,13 @@ bool Connection::doOutput() { cb(); // Lend the IO thread for management processing } } - if (mgmtClosing) + if (mgmtClosing) { + closed(); close(connection::CLOSE_CODE_CONNECTION_FORCED, "Closed by Management Request"); - else + } else { //then do other output as needed: return outputTasks.doOutput(); + } }catch(ConnectionException& e){ close(e.code, e.getMessage()); }catch(std::exception& e){ diff --git a/python/tests_0-10/management.py b/python/tests_0-10/management.py index 51c2a687cb..53573f309e 100644 --- a/python/tests_0-10/management.py +++ b/python/tests_0-10/management.py @@ -295,3 +295,25 @@ class ManagementTest (TestBase010): sleep(1) self.assertEqual(handler.check(), "pass") + def test_connection_close(self): + """ + Test management method for closing connection + """ + self.startQmf() + conn = self.connect() + session = conn.session("my-named-session") + + #using qmf find named session and close the corresponding connection: + qmf_ssn_object = self.qmf.getObjects(_class="session", name="my-named-session")[0] + qmf_ssn_object._connectionRef_.close() + + #check that connection is closed + try: + conn.session("another-session") + self.fail("Expected failure from closed connection") + except: None + + #make sure that the named session has been closed and the name can be re-used + conn = self.connect() + session = conn.session("my-named-session") + session.queue_declare(queue="whatever", exclusive=True, auto_delete=True) |