summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/Mutex.h
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-10-31 18:47:28 +0000
committerGordon Sim <gsim@apache.org>2007-10-31 18:47:28 +0000
commit7990138bb3eb014c85bfb806c91e23def530ef37 (patch)
tree50179d4837d87f9e7f079ca44088c383561c9a97 /cpp/src/qpid/sys/Mutex.h
parentff6f9f47dbbaaf84dde2a86dd8f854fcf3060378 (diff)
downloadqpid-python-7990138bb3eb014c85bfb806c91e23def530ef37.tar.gz
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
Diffstat (limited to 'cpp/src/qpid/sys/Mutex.h')
-rw-r--r--cpp/src/qpid/sys/Mutex.h12
1 files changed, 12 insertions, 0 deletions
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 L>
+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