From 61ffc0c7fd9a23dc423305f144948fbae9956bf6 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Tue, 23 Jun 2009 00:02:39 +0000 Subject: [PATCH] Guard the plugin loader. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73925 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/PluginLoader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 5acf1d13ee9..ef32af4b3f3 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -16,13 +16,16 @@ #include "llvm/Support/PluginLoader.h" #include "llvm/Support/Streams.h" #include "llvm/System/DynamicLibrary.h" +#include "llvm/System/Mutex.h" #include #include using namespace llvm; static ManagedStatic > Plugins; +static ManagedStatic > PluginsLock; void PluginLoader::operator=(const std::string &Filename) { + sys::SmartScopedLock Lock(&*PluginsLock); std::string Error; if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { cerr << "Error opening '" << Filename << "': " << Error @@ -33,10 +36,12 @@ void PluginLoader::operator=(const std::string &Filename) { } unsigned PluginLoader::getNumPlugins() { + sys::SmartScopedLock Lock(&*PluginsLock); return Plugins.isConstructed() ? Plugins->size() : 0; } std::string &PluginLoader::getPlugin(unsigned num) { + sys::SmartScopedLock Lock(&*PluginsLock); assert(Plugins.isConstructed() && num < Plugins->size() && "Asking for an out of bounds plugin"); return (*Plugins)[num]; -- 2.34.1