Bug 939790 - make SafeMutex::mOwnerThread a relaxed atomic variable; r=bsmedberg

This is similar to the solution adopted for bug 1190985, a race in
netwerk's DebugMutexAutoLock.  A relaxed atomic tells tools like TSan
that we're OK with this variable being touched from multiple threads.
That it's only set from within a locked mutex should ensure whatever
memory barriers we need are executed so all threads have a consistent
view of what value it contains.

Getting rid of another |volatile| usage in the codebase is just a bonus.
This commit is contained in:
Nathan Froyd 2015-09-11 20:57:07 -04:00
parent 16d99d45bd
commit fc3e60aac1

View File

@ -15,6 +15,7 @@
#include "nsIMemoryReporter.h"
#include "nsIServiceManager.h"
#include "nsIFile.h"
#include "mozilla/Atomics.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Module.h"
#include "mozilla/ModuleLoader.h"
@ -124,7 +125,7 @@ public:
private:
mozilla::Mutex mMutex;
volatile PRThread* mOwnerThread;
mozilla::Atomic<PRThread*, mozilla::Relaxed> mOwnerThread;
};
typedef mozilla::BaseAutoLock<SafeMutex> SafeMutexAutoLock;