From dd4e49b082eae1ada283ea547a4e1371aa426d4c Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 21 Jan 2014 18:27:32 +0000 Subject: QPID-5497: implement Session::sync() git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1560125 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/messaging/amqp/ConnectionContext.cpp | 11 +++++++++++ cpp/src/qpid/messaging/amqp/ConnectionContext.h | 1 + cpp/src/qpid/messaging/amqp/SessionHandle.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'cpp') diff --git a/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp b/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp index c9cdd075bc..b762ed036c 100644 --- a/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp +++ b/cpp/src/qpid/messaging/amqp/ConnectionContext.cpp @@ -125,6 +125,17 @@ bool ConnectionContext::isOpen() const return state == CONNECTED && pn_connection_state(connection) & (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE); } +void ConnectionContext::sync(boost::shared_ptr ssn) +{ + qpid::sys::ScopedLock l(lock); + //wait for outstanding sends to settle + while (!ssn->settled()) { + QPID_LOG(debug, "Waiting for sends to settle on sync()"); + wait(ssn);//wait until message has been confirmed + } + checkClosed(ssn); +} + void ConnectionContext::endSession(boost::shared_ptr ssn) { qpid::sys::ScopedLock l(lock); diff --git a/cpp/src/qpid/messaging/amqp/ConnectionContext.h b/cpp/src/qpid/messaging/amqp/ConnectionContext.h index 94cdefccfc..70ace473f2 100644 --- a/cpp/src/qpid/messaging/amqp/ConnectionContext.h +++ b/cpp/src/qpid/messaging/amqp/ConnectionContext.h @@ -84,6 +84,7 @@ class ConnectionContext : public qpid::sys::ConnectionCodec, public qpid::messag bool get(boost::shared_ptr ssn, boost::shared_ptr lnk, qpid::messaging::Message& message, qpid::messaging::Duration timeout); void acknowledge(boost::shared_ptr ssn, qpid::messaging::Message* message, bool cumulative); void nack(boost::shared_ptr ssn, qpid::messaging::Message& message, bool reject); + void sync(boost::shared_ptr ssn); void setOption(const std::string& name, const qpid::types::Variant& value); std::string getAuthenticatedUsername(); diff --git a/cpp/src/qpid/messaging/amqp/SessionHandle.cpp b/cpp/src/qpid/messaging/amqp/SessionHandle.cpp index 044f208564..8334876b84 100644 --- a/cpp/src/qpid/messaging/amqp/SessionHandle.cpp +++ b/cpp/src/qpid/messaging/amqp/SessionHandle.cpp @@ -75,9 +75,11 @@ void SessionHandle::close() connection->endSession(session); } -void SessionHandle::sync(bool /*block*/) +void SessionHandle::sync(bool block) { - + if (block) { + connection->sync(session); + } } qpid::messaging::Sender SessionHandle::createSender(const qpid::messaging::Address& address) -- cgit v1.2.1