summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2010-04-27 22:20:19 +0000
committerAndrew Stitcher <astitcher@apache.org>2010-04-27 22:20:19 +0000
commit7c794f4dbaf80b2eee916fb12466cec2888583a9 (patch)
treeaea56aba74b60ec0185757c41d91010ed4e52c04 /qpid/cpp/src
parent02a8cecea96a942c5fb02d3f9a8afe2ee1990952 (diff)
downloadqpid-python-7c794f4dbaf80b2eee916fb12466cec2888583a9.tar.gz
Avoid possible initialisation dependency problem by using a "static
singleton" pattern for plugin module file suffix git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@938700 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/Modules.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/qpid/cpp/src/qpid/Modules.cpp b/qpid/cpp/src/qpid/Modules.cpp
index 70549bd553..8f58df6ed1 100644
--- a/qpid/cpp/src/qpid/Modules.cpp
+++ b/qpid/cpp/src/qpid/Modules.cpp
@@ -33,14 +33,17 @@ namespace fs=boost::filesystem;
namespace {
// CMake sets QPID_MODULE_SUFFIX; Autoconf doesn't, so assume Linux .so
-#if defined (QPID_MODULE_SUFFIX)
- std::string suffix(QPID_MODULE_SUFFIX);
-#else
- std::string suffix(".so");
+#ifndef QPID_MODULE_SUFFIX
+#define QPID_MODULE_SUFFIX ".so"
#endif
+inline std::string& suffix() {
+ static std::string s(QPID_MODULE_SUFFIX);
+ return s;
+}
+
bool isShlibName(const std::string& name) {
- return name.find (suffix) == name.length() - suffix.length();
+ return name.find (suffix()) == name.length() - suffix().length();
}
}
@@ -58,7 +61,7 @@ ModuleOptions::ModuleOptions(const std::string& defaultModuleDir)
void tryShlib(const char* libname_, bool noThrow) {
std::string libname(libname_);
- if (!isShlibName(libname)) libname += suffix;
+ if (!isShlibName(libname)) libname += suffix();
try {
sys::Shlib shlib(libname);
QPID_LOG (info, "Loaded Module: " << libname);