From 3aa21a3194e32eadd1158432f2ed39d4bc931e3f Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Thu, 3 Aug 2017 15:54:36 -0400 Subject: SERVER-30147 Move Command::appendOperationTime to LogicalTime --- src/mongo/db/commands/generic.cpp | 95 +++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 48 deletions(-) (limited to 'src/mongo/db/commands/generic.cpp') diff --git a/src/mongo/db/commands/generic.cpp b/src/mongo/db/commands/generic.cpp index 35998427356..d2595b1fda9 100644 --- a/src/mongo/db/commands/generic.cpp +++ b/src/mongo/db/commands/generic.cpp @@ -63,8 +63,8 @@ #include "mongo/util/version.h" namespace mongo { +namespace { -using std::endl; using std::string; using std::stringstream; using std::vector; @@ -100,7 +100,6 @@ public: } cmdBuildInfo; - class PingCommand : public BasicCommand { public: PingCommand() : BasicCommand("ping") {} @@ -264,10 +263,10 @@ public: BSONObjBuilder& result) { // sort the commands before building the result BSON std::vector commands; - for (CommandMap::const_iterator it = _commands->begin(); it != _commands->end(); ++it) { + for (const auto command : allCommands()) { // don't show oldnames - if (it->first == it->second->getName()) - commands.push_back(it->second); + if (command.first == command.second->getName()) + commands.push_back(command.second); } std::sort(commands.begin(), commands.end(), [](Command* lhs, Command* rhs) { return (lhs->getName()) < (rhs->getName()); @@ -296,49 +295,6 @@ public: } listCommandsCmd; -namespace { -MONGO_FP_DECLARE(crashOnShutdown); - -int* volatile illegalAddress; // NOLINT - used for fail point only -} // namespace - -void CmdShutdown::addRequiredPrivileges(const std::string& dbname, - const BSONObj& cmdObj, - std::vector* out) { - ActionSet actions; - actions.addAction(ActionType::shutdown); - out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); -} - -void CmdShutdown::shutdownHelper() { - MONGO_FAIL_POINT_BLOCK(crashOnShutdown, crashBlock) { - const std::string crashHow = crashBlock.getData()["how"].str(); - if (crashHow == "fault") { - ++*illegalAddress; - } - ::abort(); - } - - log() << "terminating, shutdown command received"; - -#if defined(_WIN32) - // Signal the ServiceMain thread to shutdown. - if (ntservice::shouldStartService()) { - shutdownNoTerminate(); - - // Client expects us to abruptly close the socket as part of exiting - // so this function is not allowed to return. - // The ServiceMain thread will quit for us so just sleep until it does. - while (true) - sleepsecs(60); // Loop forever - } else -#endif - { - exitCleanly(EXIT_CLEAN); // this never returns - invariant(false); - } -} - /* for testing purposes only */ class CmdForceError : public BasicCommand { public: @@ -520,4 +476,47 @@ public: } } cmdGetCmdLineOpts; + +MONGO_FP_DECLARE(crashOnShutdown); +int* volatile illegalAddress; // NOLINT - used for fail point only + +} // namespace + +void CmdShutdown::addRequiredPrivileges(const std::string& dbname, + const BSONObj& cmdObj, + std::vector* out) { + ActionSet actions; + actions.addAction(ActionType::shutdown); + out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } + +void CmdShutdown::shutdownHelper() { + MONGO_FAIL_POINT_BLOCK(crashOnShutdown, crashBlock) { + const std::string crashHow = crashBlock.getData()["how"].str(); + if (crashHow == "fault") { + ++*illegalAddress; + } + ::abort(); + } + + log() << "terminating, shutdown command received"; + +#if defined(_WIN32) + // Signal the ServiceMain thread to shutdown. + if (ntservice::shouldStartService()) { + shutdownNoTerminate(); + + // Client expects us to abruptly close the socket as part of exiting + // so this function is not allowed to return. + // The ServiceMain thread will quit for us so just sleep until it does. + while (true) + sleepsecs(60); // Loop forever + } else +#endif + { + exitCleanly(EXIT_CLEAN); // this never returns + invariant(false); + } +} + +} // namespace mongo -- cgit v1.2.1