From ec2a87c8b4d5873c3ea4e88e7c02e1b6200400ea Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 12 Jun 2008 19:19:22 +0000 Subject: Propagate error messages across the Demux between network & user threads. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@667205 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/client/Demux.cpp | 8 ++++---- qpid/cpp/src/qpid/client/Demux.h | 2 +- qpid/cpp/src/qpid/client/SessionImpl.cpp | 4 +++- qpid/cpp/src/qpid/sys/BlockingQueue.h | 7 ++++--- qpid/cpp/src/tests/Makefile.am | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) (limited to 'qpid/cpp/src') diff --git a/qpid/cpp/src/qpid/client/Demux.cpp b/qpid/cpp/src/qpid/client/Demux.cpp index cb9372cee7..b774214ae4 100644 --- a/qpid/cpp/src/qpid/client/Demux.cpp +++ b/qpid/cpp/src/qpid/client/Demux.cpp @@ -47,7 +47,7 @@ ScopedDivert::~ScopedDivert() Demux::Demux() : defaultQueue(new Queue()) {} -Demux::~Demux() { close(); } +Demux::~Demux() { close(sys::ExceptionHolder(new ClosedException())); } Demux::QueuePtr ScopedDivert::getQueue() { @@ -69,13 +69,13 @@ void Demux::handle(framing::FrameSet::shared_ptr frameset) } } -void Demux::close() +void Demux::close(const sys::ExceptionHolder& ex) { sys::Mutex::ScopedLock l(lock); for (iterator i = records.begin(); i != records.end(); i++) { - i->queue->close(); + i->queue->close(ex); } - defaultQueue->close(); + defaultQueue->close(ex); } void Demux::open() diff --git a/qpid/cpp/src/qpid/client/Demux.h b/qpid/cpp/src/qpid/client/Demux.h index 5c640f99d2..7304e799bb 100644 --- a/qpid/cpp/src/qpid/client/Demux.h +++ b/qpid/cpp/src/qpid/client/Demux.h @@ -53,7 +53,7 @@ public: ~Demux(); void handle(framing::FrameSet::shared_ptr); - void close(); + void close(const sys::ExceptionHolder& ex); void open(); QueuePtr add(const std::string& name, Condition); diff --git a/qpid/cpp/src/qpid/client/SessionImpl.cpp b/qpid/cpp/src/qpid/client/SessionImpl.cpp index 7b8cae943f..574c71ecd7 100644 --- a/qpid/cpp/src/qpid/client/SessionImpl.cpp +++ b/qpid/cpp/src/qpid/client/SessionImpl.cpp @@ -616,7 +616,9 @@ void SessionImpl::assertOpen() const void SessionImpl::handleClosed() { - demux.close(); + // FIXME aconway 2008-06-12: needs to be set to the correct exception type. + // + demux.close(sys::ExceptionHolder(text.empty() ? new ClosedException() : new Exception(text))); results.close(); } diff --git a/qpid/cpp/src/qpid/sys/BlockingQueue.h b/qpid/cpp/src/qpid/sys/BlockingQueue.h index dd709c6bff..86020fad81 100644 --- a/qpid/cpp/src/qpid/sys/BlockingQueue.h +++ b/qpid/cpp/src/qpid/sys/BlockingQueue.h @@ -79,13 +79,14 @@ public: } /** - * Close the queue. Throws ClosedException in threads waiting in pop(). - * Blocks till all waiting threads have been notified. + * Close the queue. + *@ex exception to throw to waiting threads. ClosedException by default. */ - void close() + void close(const ExceptionHolder& ex=ExceptionHolder(new ClosedException())) { Waitable::ScopedLock l(lock); if (!closed) { + lock.setException(ex); closed = true; lock.notifyAll(); lock.waitWaiters(); // Ensure no threads are still waiting. diff --git a/qpid/cpp/src/tests/Makefile.am b/qpid/cpp/src/tests/Makefile.am index 735d85b419..57d1c04b72 100644 --- a/qpid/cpp/src/tests/Makefile.am +++ b/qpid/cpp/src/tests/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS = $(WARNING_CFLAGS) $(CFLAGS) $(APR_CXXFLAGS) -DBOOST_TEST_DYN_LINK +AM_CXXFLAGS = $(WARNING_CFLAGS) -DBOOST_TEST_DYN_LINK INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../gen -I$(top_builddir)/src/gen abs_builddir=@abs_builddir@ -- cgit v1.2.1