From 7990138bb3eb014c85bfb806c91e23def530ef37 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Wed, 31 Oct 2007 18:47:28 +0000 Subject: Simple fix to prevent concurrent disconnection and sending of frames causing seg faults. A more complete solution may follow. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@590786 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/Mutex.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cpp/src/qpid/sys/Mutex.h') diff --git a/cpp/src/qpid/sys/Mutex.h b/cpp/src/qpid/sys/Mutex.h index b8545d4449..b4bd3a9b4a 100644 --- a/cpp/src/qpid/sys/Mutex.h +++ b/cpp/src/qpid/sys/Mutex.h @@ -66,6 +66,18 @@ class ScopedWlock L& mutex; }; +template +class ConditionalScopedLock +{ + public: + ConditionalScopedLock(L& l) : mutex(l) { acquired = l.trylock(); } + ~ConditionalScopedLock() { if (acquired) mutex.unlock(); } + bool lockAcquired() { return acquired; } + private: + L& mutex; + bool acquired; +}; + }} #ifdef USE_APR_PLATFORM -- cgit v1.2.1