summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2016-06-16 12:48:30 -0400
committerAndrew Morrow <acm@mongodb.com>2017-02-27 23:38:16 -0500
commit9dfb28da2fbf9b1ba6b17ad873dde0db1863694f (patch)
tree5595f7fb6970f49f258034121b5dbcdf1c824b81
parent27026169e795dc090e692fb27f93645e6646be48 (diff)
downloadmongo-9dfb28da2fbf9b1ba6b17ad873dde0db1863694f.tar.gz
SERVER-28094 Remove the StaticObserver
-rw-r--r--etc/lsan.suppressions5
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/client/replica_set_monitor.cpp4
-rw-r--r--src/mongo/db/commands.h1
-rw-r--r--src/mongo/db/db.cpp3
-rw-r--r--src/mongo/dbtests/dbtests.cpp2
-rw-r--r--src/mongo/s/server.cpp3
-rw-r--r--src/mongo/shell/dbshell.cpp3
-rw-r--r--src/mongo/tools/bridge.cpp2
-rw-r--r--src/mongo/util/concurrency/mutex.h10
-rw-r--r--src/mongo/util/static_observer.cpp37
-rw-r--r--src/mongo/util/static_observer.h48
12 files changed, 4 insertions, 115 deletions
diff --git a/etc/lsan.suppressions b/etc/lsan.suppressions
index b2bb87a3b95..8d0eaea9296 100644
--- a/etc/lsan.suppressions
+++ b/etc/lsan.suppressions
@@ -1,11 +1,6 @@
# Client objects are leaked in threads that are never terminated
leak:mongo::Client::Client
-# Insanity related to the fact that the static observer
-# prevents deleting mutexes during clean shutdown. If you
-# remove the StaticObserver, remove this too.
-leak:mongo::mutex::mutex
-
# Thread names leak from threads that are never terminated.
leak:mongo::setThreadName
leak:mongo::getThreadName
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 59ff55e6156..a8aab08791e 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -119,7 +119,6 @@ baseSource=[
'util/stacktrace.cpp',
'util/stacktrace_${TARGET_OS_FAMILY}.cpp',
'util/startup_test.cpp',
- 'util/static_observer.cpp',
'util/stringutils.cpp',
'util/system_clock_source.cpp',
'util/system_tick_source.cpp',
diff --git a/src/mongo/client/replica_set_monitor.cpp b/src/mongo/client/replica_set_monitor.cpp
index 2d58216994e..9b762f07708 100644
--- a/src/mongo/client/replica_set_monitor.cpp
+++ b/src/mongo/client/replica_set_monitor.cpp
@@ -47,12 +47,10 @@
#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
#include "mongo/util/background.h"
-#include "mongo/util/concurrency/mutex.h" // for StaticObserver
#include "mongo/util/debug_util.h"
#include "mongo/util/exit.h"
#include "mongo/util/fail_point_service.h"
#include "mongo/util/log.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/string_map.h"
#include "mongo/util/timer.h"
@@ -95,8 +93,6 @@ const Milliseconds kFindHostMaxBackOffTime(500);
ReplicaSetMonitor::ConfigChangeHook asyncConfigChangeHook;
ReplicaSetMonitor::ConfigChangeHook syncConfigChangeHook;
-StaticObserver staticObserver;
-
//
// Helpers for stl algorithms
//
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index 6da42631534..263a96988b6 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -362,7 +362,6 @@ public:
* mongo initializers:
*
* int myMain(int argc, char** argv, char** envp) {
- * static StaticObserver StaticObserver;
* Command::testCommandsEnabled = true;
* ...
* runGlobalInitializersOrDie(argc, argv, envp);
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index b6af9e55f4a..251e08824a3 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -140,7 +140,6 @@
#include "mongo/util/signal_handlers.h"
#include "mongo/util/stacktrace.h"
#include "mongo/util/startup_test.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/text.h"
#include "mongo/util/time_support.h"
#include "mongo/util/version.h"
@@ -1050,8 +1049,6 @@ static void shutdownTask() {
}
static int mongoDbMain(int argc, char* argv[], char** envp) {
- static StaticObserver staticObserver;
-
registerShutdownTask(shutdownTask);
setupSignalHandlers();
diff --git a/src/mongo/dbtests/dbtests.cpp b/src/mongo/dbtests/dbtests.cpp
index 52f5f2a4888..12cb6ff9d06 100644
--- a/src/mongo/dbtests/dbtests.cpp
+++ b/src/mongo/dbtests/dbtests.cpp
@@ -56,7 +56,6 @@
#include "mongo/util/quick_exit.h"
#include "mongo/util/signal_handlers_synchronous.h"
#include "mongo/util/startup_test.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/text.h"
namespace mongo {
@@ -125,7 +124,6 @@ Status createIndexFromSpec(OperationContext* txn, StringData ns, const BSONObj&
int dbtestsMain(int argc, char** argv, char** envp) {
- static StaticObserver StaticObserver;
Command::testCommandsEnabled = true;
::mongo::setupSynchronousSignalHandlers();
mongo::dbtests::initWireSpec();
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index 3fd4d4fb3dc..61784799c0f 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -101,7 +101,6 @@
#include "mongo/util/quick_exit.h"
#include "mongo/util/signal_handlers.h"
#include "mongo/util/stacktrace.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/stringutils.h"
#include "mongo/util/system_clock_source.h"
#include "mongo/util/system_tick_source.h"
@@ -449,7 +448,7 @@ MONGO_INITIALIZER_GENERAL(setSSLManagerType, MONGO_NO_PREREQUISITES, ("SSLManage
int mongoSMain(int argc, char* argv[], char** envp) {
mongo::setMongos();
- static StaticObserver staticObserver;
+
if (argc < 1)
return EXIT_FAILURE;
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 254ffc43359..7e1703072ef 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -66,7 +66,6 @@
#include "mongo/util/signal_handlers.h"
#include "mongo/util/stacktrace.h"
#include "mongo/util/startup_test.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/stringutils.h"
#include "mongo/util/text.h"
#include "mongo/util/version.h"
@@ -959,7 +958,6 @@ int _main(int argc, char* argv[], char** envp) {
#ifdef _WIN32
int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
- static mongo::StaticObserver staticObserver;
int returnCode;
try {
WindowsCommandLine wcl(argc, argvW, envpW);
@@ -972,7 +970,6 @@ int wmain(int argc, wchar_t* argvW[], wchar_t* envpW[]) {
}
#else // #ifdef _WIN32
int main(int argc, char* argv[], char** envp) {
- static mongo::StaticObserver staticObserver;
int returnCode;
try {
returnCode = _main(argc, argv, envp);
diff --git a/src/mongo/tools/bridge.cpp b/src/mongo/tools/bridge.cpp
index 1d061edd382..1963e92a7fa 100644
--- a/src/mongo/tools/bridge.cpp
+++ b/src/mongo/tools/bridge.cpp
@@ -59,7 +59,6 @@
#include "mongo/util/net/message.h"
#include "mongo/util/quick_exit.h"
#include "mongo/util/signal_handlers.h"
-#include "mongo/util/static_observer.h"
#include "mongo/util/text.h"
#include "mongo/util/time_support.h"
#include "mongo/util/timer.h"
@@ -384,7 +383,6 @@ MONGO_INITIALIZER(SetGlobalEnvironment)(InitializerContext* context) {
} // namespace
int bridgeMain(int argc, char** argv, char** envp) {
- static StaticObserver staticObserver;
registerShutdownTask([&] {
// NOTE: This function may be called at any time. It must not
diff --git a/src/mongo/util/concurrency/mutex.h b/src/mongo/util/concurrency/mutex.h
index c0253057de4..b2b2ab03df0 100644
--- a/src/mongo/util/concurrency/mutex.h
+++ b/src/mongo/util/concurrency/mutex.h
@@ -35,8 +35,8 @@
#include <pthread.h>
#endif
+#include "mongo/base/disallow_copying.h"
#include "mongo/util/assert_util.h"
-#include "mongo/util/static_observer.h"
namespace mongo {
@@ -57,9 +57,7 @@ public:
}
~SimpleMutex() {
- if (!StaticObserver::_destroyingStatics) {
- DeleteCriticalSection(&_cs);
- }
+ DeleteCriticalSection(&_cs);
}
void lock() {
@@ -84,9 +82,7 @@ public:
}
~SimpleMutex() {
- if (!StaticObserver::_destroyingStatics) {
- verify(pthread_mutex_destroy(&_lock) == 0);
- }
+ verify(pthread_mutex_destroy(&_lock) == 0);
}
void lock() {
diff --git a/src/mongo/util/static_observer.cpp b/src/mongo/util/static_observer.cpp
deleted file mode 100644
index 26c7bb45baf..00000000000
--- a/src/mongo/util/static_observer.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (C) 2015 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects for
- * all of the code used other than as permitted herein. If you modify file(s)
- * with this exception, you may extend this exception to your version of the
- * file(s), but you are not obligated to do so. If you do not wish to do so,
- * delete this exception statement from your version. If you delete this
- * exception statement from all source files in the program, then also delete
- * it in the license file.
- */
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/util/static_observer.h"
-
-namespace mongo {
-
-bool StaticObserver::_destroyingStatics = false;
-
-} // namespace mongo
diff --git a/src/mongo/util/static_observer.h b/src/mongo/util/static_observer.h
deleted file mode 100644
index 0f1a0b93c0e..00000000000
--- a/src/mongo/util/static_observer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2015 MongoDB Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-#pragma once
-
-#include "mongo/base/disallow_copying.h"
-
-namespace mongo {
-
-// If you create a local static instance of this class, that instance will be destroyed
-// before all global static objects are destroyed, so _destroyingStatics will be set
-// to true before the global static variables are destroyed.
-class StaticObserver {
- MONGO_DISALLOW_COPYING(StaticObserver);
-
-public:
- static bool _destroyingStatics;
- StaticObserver() = default;
- ~StaticObserver() {
- _destroyingStatics = true;
- }
-};
-
-} // namespace mongo