summaryrefslogtreecommitdiff
path: root/src/mongo/tools/mongobridge_options.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-10-18 18:22:30 -0400
committerShaun Verch <shaun.verch@10gen.com>2013-10-23 19:41:30 -0400
commit89218f62b7ad5114df7e956bec47b4c1f96f1fed (patch)
tree93a8e4deccf34642057a8d3e7a98b5093a8a9c73 /src/mongo/tools/mongobridge_options.cpp
parent107978292c125ebb6674ad57548f1a4dc8f977d1 (diff)
downloadmongo-89218f62b7ad5114df7e956bec47b4c1f96f1fed.tar.gz
SERVER-11144 Do not call _exit directly in any options handling functions
Diffstat (limited to 'src/mongo/tools/mongobridge_options.cpp')
-rw-r--r--src/mongo/tools/mongobridge_options.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/mongo/tools/mongobridge_options.cpp b/src/mongo/tools/mongobridge_options.cpp
index 8ce860d0db5..180632b7a9c 100644
--- a/src/mongo/tools/mongobridge_options.cpp
+++ b/src/mongo/tools/mongobridge_options.cpp
@@ -61,27 +61,23 @@ namespace mongo {
*out << std::flush;
}
- Status handlePreValidationMongoBridgeOptions(const moe::Environment& params) {
+ bool handlePreValidationMongoBridgeOptions(const moe::Environment& params) {
if (params.count("help")) {
printMongoBridgeHelp(&std::cout);
- ::_exit(0);
+ return true;
}
- return Status::OK();
+ return false;
}
Status storeMongoBridgeOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (!params.count("port")) {
- std::cerr << "Missing required option: \"--port\"" << std::endl;
- printMongoBridgeHelp(&std::cerr);
- ::_exit(0);
+ return Status(ErrorCodes::BadValue, "Missing required option: \"--port\"");
}
if (!params.count("dest")) {
- std::cerr << "Missing required option: \"--dest\"" << std::endl;
- printMongoBridgeHelp(&std::cerr);
- ::_exit(0);
+ return Status(ErrorCodes::BadValue, "Missing required option: \"--dest\"");
}
mongoBridgeGlobalParams.port = params["port"].as<int>();
@@ -99,11 +95,10 @@ namespace mongo {
}
MONGO_STARTUP_OPTIONS_VALIDATE(MongoBridgeOptions)(InitializerContext* context) {
- Status ret = handlePreValidationMongoBridgeOptions(moe::startupOptionsParsed);
- if (!ret.isOK()) {
- return ret;
+ if (handlePreValidationMongoBridgeOptions(moe::startupOptionsParsed)) {
+ ::_exit(EXIT_SUCCESS);
}
- ret = moe::startupOptionsParsed.validate();
+ Status ret = moe::startupOptionsParsed.validate();
if (!ret.isOK()) {
return ret;
}
@@ -111,7 +106,14 @@ namespace mongo {
}
MONGO_STARTUP_OPTIONS_STORE(MongoBridgeOptions)(InitializerContext* context) {
- return storeMongoBridgeOptions(moe::startupOptionsParsed, context->args());
+ Status ret = storeMongoBridgeOptions(moe::startupOptionsParsed, context->args());
+ if (!ret.isOK()) {
+ std::cerr << ret.toString() << std::endl;
+ std::cerr << "try '" << context->args()[0] << " --help' for more information"
+ << std::endl;
+ ::_exit(EXIT_BADOPTIONS);
+ }
+ return Status::OK();
}
}