diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/AddressResolution.cpp | 13 | ||||
-rw-r--r-- | cpp/src/qpid/client/amqp0_10/SessionImpl.cpp | 14 | ||||
-rw-r--r-- | cpp/src/tests/MessagingSessionTests.cpp | 4 |
3 files changed, 25 insertions, 6 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp index fca9b61fdb..e215d03937 100644 --- a/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp +++ b/cpp/src/qpid/client/amqp0_10/AddressResolution.cpp @@ -598,7 +598,11 @@ void Queue::checkCreate(qpid::client::AsyncSession& session, CheckMode mode) void Queue::checkDelete(qpid::client::AsyncSession& session, CheckMode mode) { - if (enabled(deletePolicy, mode)) { + //Note: queue-delete will cause a session exception if the queue + //does not exist, the query here prevents obvious cases of this + //but there is a race whenever two deletions are made concurrently + //so careful use of the delete policy is recommended at present + if (enabled(deletePolicy, mode) && sync(session).queueQuery(name).getQueue() == name) { QPID_LOG(debug, "Auto-deleting queue '" << name << "'"); sync(session).queueDelete(arg::queue=name); } @@ -683,7 +687,12 @@ void Exchange::checkCreate(qpid::client::AsyncSession& session, CheckMode mode) void Exchange::checkDelete(qpid::client::AsyncSession& session, CheckMode mode) { - if (enabled(deletePolicy, mode)) { + //Note: exchange-delete will cause a session exception if the + //exchange does not exist, the query here prevents obvious cases + //of this but there is a race whenever two deletions are made + //concurrently so careful use of the delete policy is recommended + //at present + if (enabled(deletePolicy, mode) && !sync(session).exchangeQuery(name).getNotFound()) { sync(session).exchangeDelete(arg::exchange=name); } } diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp index 3a8992d503..8545347b8c 100644 --- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp +++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp @@ -94,6 +94,20 @@ void SessionImpl::reject(qpid::messaging::Message& m) void SessionImpl::close() { + //cancel all the senders and receivers (get copy of names and then + //make the calls to avoid modifying maps while iterating over + //them): + std::vector<std::string> s; + std::vector<std::string> r; + { + qpid::sys::Mutex::ScopedLock l(lock); + for (Senders::const_iterator i = senders.begin(); i != senders.end(); ++i) s.push_back(i->first); + for (Receivers::const_iterator i = receivers.begin(); i != receivers.end(); ++i) r.push_back(i->first); + } + for (std::vector<std::string>::const_iterator i = s.begin(); i != s.end(); ++i) getSender(*i).cancel(); + for (std::vector<std::string>::const_iterator i = r.begin(); i != r.end(); ++i) getReceiver(*i).cancel(); + + connection.closed(*this); session.close(); } diff --git a/cpp/src/tests/MessagingSessionTests.cpp b/cpp/src/tests/MessagingSessionTests.cpp index 16455bc974..5b030f0f31 100644 --- a/cpp/src/tests/MessagingSessionTests.cpp +++ b/cpp/src/tests/MessagingSessionTests.cpp @@ -607,10 +607,6 @@ struct DeletePolicyFixture : public MessagingFixture BOOST_CHECK(!exists(address)); break; case ALWAYS: - //Problematic case at present; multiple attempts to delete - //will result in all but one attempt failing and killing - //the session which is not desirable. TODO: better - //implementation of delete policy. s.cancel(); BOOST_CHECK(!exists(address)); break; |