aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/CrashRecoveryContext.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:34 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-17 22:32:34 +0000
commitc0c815e887d72414894930b62221acc32488c2d0 (patch)
tree0a00dd0b5bf8784bd35ebf9a8e227f9d572d98af /lib/Support/CrashRecoveryContext.cpp
parent6cf64a631a1522c137a1fcf88858ea1336822abf (diff)
CrashRecovery: Make CrashRecoveryContext static methods thread safe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111307 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CrashRecoveryContext.cpp')
-rw-r--r--lib/Support/CrashRecoveryContext.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Support/CrashRecoveryContext.cpp b/lib/Support/CrashRecoveryContext.cpp
index de98132539..d1ecbb74da 100644
--- a/lib/Support/CrashRecoveryContext.cpp
+++ b/lib/Support/CrashRecoveryContext.cpp
@@ -10,6 +10,7 @@
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Config/config.h"
+#include "llvm/System/Mutex.h"
#include "llvm/System/ThreadLocal.h"
#include <setjmp.h>
#include <cstdio>
@@ -47,6 +48,7 @@ public:
}
+static sys::Mutex gCrashRecoveryContexMutex;
static bool gCrashRecoveryEnabled = false;
CrashRecoveryContext::~CrashRecoveryContext() {
@@ -59,6 +61,8 @@ CrashRecoveryContext::~CrashRecoveryContext() {
// FIXME: No real Win32 implementation currently.
void CrashRecoveryContext::Enable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (gCrashRecoveryEnabled)
return;
@@ -66,6 +70,8 @@ void CrashRecoveryContext::Enable() {
}
void CrashRecoveryContext::Disable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (!gCrashRecoveryEnabled)
return;
@@ -121,6 +127,8 @@ static void CrashRecoverySignalHandler(int Signal) {
}
void CrashRecoveryContext::Enable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (gCrashRecoveryEnabled)
return;
@@ -138,6 +146,8 @@ void CrashRecoveryContext::Enable() {
}
void CrashRecoveryContext::Disable() {
+ sys::ScopedLock L(gCrashRecoveryContexMutex);
+
if (!gCrashRecoveryEnabled)
return;