You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/07/06 20:23:44 UTC
svn commit: r553982 - in
/activemq/activemq-cpp/trunk/src/main/activemq/concurrent: Lock.h Mutex.cpp
Author: tabish
Date: Fri Jul 6 11:23:43 2007
New Revision: 553982
URL: http://svn.apache.org/viewvc?view=rev&rev=553982
Log:
http://issues.apache.org/activemq/browse/AMQCPP-128
Fixed error handling in Mutex
Modified:
activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Lock.h
activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Mutex.cpp
Modified: activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Lock.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Lock.h?view=diff&rev=553982&r1=553981&r2=553982
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Lock.h (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Lock.h Fri Jul 6 11:23:43 2007
@@ -36,7 +36,7 @@
* Flag to indicate whether or not this object has locked the
* sync object.
*/
- bool locked;
+ volatile bool locked;
/**
* The synchronizable object to lock/unlock.
@@ -58,8 +58,7 @@
syncObject = object;
locked = false;
- if( intiallyLocked )
- {
+ if( intiallyLocked ) {
lock();
}
}
@@ -73,8 +72,7 @@
virtual ~Lock()
{
try{
- if( locked )
- {
+ if( locked ) {
syncObject->unlock();
}
}
@@ -101,8 +99,7 @@
void unlock()
{
try{
- if(locked)
- {
+ if(locked) {
syncObject->unlock();
locked = false;
}
Modified: activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Mutex.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Mutex.cpp?view=diff&rev=553982&r1=553981&r2=553982
==============================================================================
--- activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Mutex.cpp (original)
+++ activemq/activemq-cpp/trunk/src/main/activemq/concurrent/Mutex.cpp Fri Jul 6 11:23:43 2007
@@ -166,7 +166,7 @@
if( waitEvent == NULL ) {
throw exceptions::ActiveMQException(
__FILE__, __LINE__,
- "Mutex::Mutex - Failed Creating Event." );
+ "Mutex::wait - Failed Creating Event." );
}
eventQ.push_back( waitEvent );
@@ -175,7 +175,11 @@
LeaveCriticalSection( &mutex );
// Wait for a signal
- WaitForSingleObject( waitEvent, millisecs );
+ if( WaitForSingleObject( waitEvent, millisecs ) != WAIT_OBJECT_0 && millisecs == WAIT_INFINITE ) {
+ throw exceptions::ActiveMQException(
+ __FILE__, __LINE__,
+ "Mutex::wait - Infinite wait aborted for unknown reason." );
+ }
// Reaquire the Lock
EnterCriticalSection( &mutex );