From: Mukund Sivaraman Date: Fri, 19 Oct 2012 00:14:58 +0000 (+0530) Subject: [2198] Move get methods into unnamed namespace X-Git-Tag: trac2402_base~10^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e199b28f4247ba178c4a066d77c6ff6dbebfd19;p=thirdparty%2Fkea.git [2198] Move get methods into unnamed namespace --- diff --git a/src/lib/util/interprocess_sync_file.cc b/src/lib/util/interprocess_sync_file.cc index 509a19c7c2..253720a23c 100644 --- a/src/lib/util/interprocess_sync_file.cc +++ b/src/lib/util/interprocess_sync_file.cc @@ -16,6 +16,8 @@ #include +#include + #include #include #include @@ -28,6 +30,33 @@ using namespace isc::util::thread; namespace isc { namespace util { +namespace { // unnamed namespace + +typedef std::map > + SyncMap; + +SyncMap& +getSyncMap() { + // avoid static destruction fiasco when the SyncMap is destroyed + // before clients which use it such as logger objects. This leaks, + // but isn't a growing leak. + static SyncMap* sync_map = new SyncMap; + + return (*sync_map); +} + +Mutex& +getSyncMapMutex() { + // avoid static destruction fiasco when the Mutex is destroyed + // before clients which use it such as logger objects. This leaks, + // but isn't a growing leak. + static Mutex* sync_map_mutex = new Mutex; + + return (*sync_map_mutex); +} + +} // end of unnamed namespace + InterprocessSyncFile::InterprocessSyncFile(const std::string& task_name) : InterprocessSync(task_name), fd_(-1) @@ -74,26 +103,6 @@ InterprocessSyncFile::~InterprocessSyncFile() { // destruction when basic block is exited. } -InterprocessSyncFile::SyncMap& -InterprocessSyncFile::getSyncMap() { - // avoid static destruction fiasco when the SyncMap is destroyed - // before clients which use it such as logger objects. This leaks, - // but isn't a growing leak. - static SyncMap* sync_map = new SyncMap; - - return (*sync_map); -} - -Mutex& -InterprocessSyncFile::getSyncMapMutex() { - // avoid static destruction fiasco when the Mutex is destroyed - // before clients which use it such as logger objects. This leaks, - // but isn't a growing leak. - static Mutex* sync_map_mutex = new Mutex; - - return (*sync_map_mutex); -} - bool InterprocessSyncFile::do_lock(int cmd, short l_type) { // Open lock file only when necessary (i.e., here). This is so that diff --git a/src/lib/util/interprocess_sync_file.h b/src/lib/util/interprocess_sync_file.h index e4fb3241d7..c9ae0d4583 100644 --- a/src/lib/util/interprocess_sync_file.h +++ b/src/lib/util/interprocess_sync_file.h @@ -21,7 +21,6 @@ #include -#include #include namespace isc { @@ -86,11 +85,7 @@ protected: private: typedef boost::shared_ptr MutexPtr; typedef boost::shared_ptr LockerPtr; - typedef std::map > - SyncMap; - SyncMap& getSyncMap(); - isc::util::thread::Mutex& getSyncMapMutex(); bool do_lock(int cmd, short l_type); int fd_; ///< The descriptor for the open file