summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2017-02-28 14:21:49 -0500
committerMark Benvenuto <mark.benvenuto@mongodb.com>2017-02-28 14:21:49 -0500
commit9bf92ae98e3621a31df91c6150f34ff3fa1213c7 (patch)
tree19c48d8c9d3a719a219b373f8ee594edac8231a8 /src/mongo/util
parente52c6669b07d2ab8057fe1eacf86335c29281e79 (diff)
downloadmongo-9bf92ae98e3621a31df91c6150f34ff3fa1213c7.tar.gz
SERVER-6065 NT Service stop does not exit cleanly
(cherry picked from commit 50e9769099bb49220783f95c9045dd1259a18eb4)
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/exit.cpp2
-rw-r--r--src/mongo/util/ntservice.cpp13
2 files changed, 6 insertions, 9 deletions
diff --git a/src/mongo/util/exit.cpp b/src/mongo/util/exit.cpp
index 39ca2ec611f..eb260dbcf53 100644
--- a/src/mongo/util/exit.cpp
+++ b/src/mongo/util/exit.cpp
@@ -159,7 +159,7 @@ void shutdownNoTerminate() {
{
stdx::lock_guard<stdx::mutex> lock(shutdownMutex);
shutdownTasksInProgress = false;
- shutdownExitCode.emplace(EXIT_WINDOWS_SERVICE_STOP);
+ shutdownExitCode.emplace(EXIT_CLEAN);
}
shutdownTasksComplete.notify_all();
diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp
index 8044d26790d..083b2fcc210 100644
--- a/src/mongo/util/ntservice.cpp
+++ b/src/mongo/util/ntservice.cpp
@@ -524,25 +524,22 @@ bool reportStatus(DWORD reportState, DWORD waitHint, DWORD exitCode) {
// Minimum of time we tell Windows to wait before we are guilty of a hung shutdown
const int kStopWaitHintMillis = 30000;
-// Run exitCleanly on a separate thread so we can report progress to Windows
+// Run shutdownNoTerminate on a separate thread so we can report progress to Windows
// Note: Windows may still kill us for taking too long,
// On client OSes, SERVICE_CONTROL_SHUTDOWN has a 5 second timeout configured in
// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
static void serviceStop() {
- // VS2013 Doesn't support future<void>, so fake it with a bool.
- stdx::packaged_task<bool()> exitCleanlyTask([] {
+ stdx::packaged_task<void()> shutdownNoTerminateTask([] {
setThreadName("serviceStopWorker");
// Stop the process
- // TODO: SERVER-5703, separate the "cleanup for shutdown" functionality from
- // the "terminate process" functionality in exitCleanly.
- exitCleanly(EXIT_WINDOWS_SERVICE_STOP);
+ shutdownNoTerminate();
return true;
});
- stdx::future<bool> exitedCleanly = exitCleanlyTask.get_future();
+ stdx::future<void> exitedCleanly = shutdownNoTerminateTask.get_future();
// Launch the packaged task in a thread. We needn't ever join it,
// so it doesn't even need a name.
- stdx::thread(std::move(exitCleanlyTask)).detach();
+ stdx::thread(std::move(shutdownNoTerminateTask)).detach();
const auto timeout = Milliseconds(kStopWaitHintMillis / 2);