summaryrefslogtreecommitdiff
path: root/src/mongo/base/initializer.cpp
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2013-05-23 10:44:44 -0400
committerEric Milkie <milkie@10gen.com>2013-05-23 10:44:44 -0400
commitc3c8ec43d247635a2c6c418ce7f540b2c34390ea (patch)
treea294ba622b2f7c78b3aa0877a445623b20b16bc5 /src/mongo/base/initializer.cpp
parentb7c80ec25658288217947e3d4aaf1e27826bb578 (diff)
downloadmongo-c3c8ec43d247635a2c6c418ce7f540b2c34390ea.tar.gz
SERVER-9768 create non-dying entry point for running initializers, for use by C++ driver users
Diffstat (limited to 'src/mongo/base/initializer.cpp')
-rw-r--r--src/mongo/base/initializer.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/mongo/base/initializer.cpp b/src/mongo/base/initializer.cpp
index 42075d59b15..940d7e5df0f 100644
--- a/src/mongo/base/initializer.cpp
+++ b/src/mongo/base/initializer.cpp
@@ -55,21 +55,10 @@ namespace mongo {
Status runGlobalInitializers(const InitializerContext::ArgumentVector& args,
const InitializerContext::EnvironmentMap& env) {
-
return getGlobalInitializer().execute(args, env);
}
- void runGlobalInitializersOrDie(const InitializerContext::ArgumentVector& args,
- const InitializerContext::EnvironmentMap& env) {
-
- Status status = runGlobalInitializers(args, env);
- if (Status::OK() != status) {
- std::cerr << "Failed global initialization: " << status << std::endl;
- ::_exit(1);
- }
- }
-
- void runGlobalInitializersOrDie(int argc, const char* const* argv, const char* const* envp) {
+ Status runGlobalInitializers(int argc, const char* const* argv, const char* const* envp) {
InitializerContext::ArgumentVector args(argc);
std::copy(argv, argv + argc, args.begin());
@@ -79,14 +68,21 @@ namespace mongo {
for(; *envp; ++envp) {
const char* firstEqualSign = strchr(*envp, '=');
if (!firstEqualSign) {
- std::cerr << "Failed global initialization: malformed environment block\n";
- ::_exit(1);
+ return Status(ErrorCodes::BadValue, "malformed environment block");
}
env[std::string(*envp, firstEqualSign)] = std::string(firstEqualSign + 1);
}
}
- runGlobalInitializersOrDie(args, env);
+ return runGlobalInitializers(args, env);
+ }
+
+ void runGlobalInitializersOrDie(int argc, const char* const* argv, const char* const* envp) {
+ Status status = runGlobalInitializers(argc, argv, envp);
+ if (!status.isOK()) {
+ std::cerr << "Failed global initialization: " << status << std::endl;
+ ::_exit(1);
+ }
}
} // namespace mongo