From: <z-...@us...> - 2011-08-25 11:25:45
|
Revision: 9740 http://armagetronad.svn.sourceforge.net/armagetronad/?rev=9740&view=rev Author: z-man Date: 2011-08-25 11:25:39 +0000 (Thu, 25 Aug 2011) Log Message: ----------- Fixing possible race condition when two threads release the last two references to an object at the same time. Now only one of them will delete the object. Modified Paths: -------------- armagetronad/branches/0.2.8.3/armagetronad/src/tools/tSafePTR.h Modified: armagetronad/branches/0.2.8.3/armagetronad/src/tools/tSafePTR.h =================================================================== --- armagetronad/branches/0.2.8.3/armagetronad/src/tools/tSafePTR.h 2011-08-25 11:24:46 UTC (rev 9739) +++ armagetronad/branches/0.2.8.3/armagetronad/src/tools/tSafePTR.h 2011-08-25 11:25:39 UTC (rev 9740) @@ -458,9 +458,10 @@ tASSERT ( this && refCtr_ >= 0 ); mutex_.acquire(); --refCtr_; + bool kill = (refCtr_ <= 0); mutex_.release(); - if ( refCtr_ <= 0 ) + if ( kill ) { refCtr_ = -1000; delete static_cast< const T* >( this ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |