From f8a99ea469f5ad3b973c0d1ca47f8b44f25a3dd9 Mon Sep 17 00:00:00 2001 From: Andrew Morrow Date: Fri, 7 Mar 2014 11:51:03 -0500 Subject: [PATCH] CXX-77 Backport relevant server repo changes applied between rc0 and rc1 --- SConstruct | 10 ++++----- src/mongo/base/error_codes.err | 4 +++- src/mongo/base/generate_error_codes.py | 31 +++++++++++++++----------- src/mongo/base/status-inl.h | 2 +- src/mongo/base/status.h | 2 +- src/mongo/util/assert_util.h | 7 ------ src/mongo/util/version.cpp | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/SConstruct b/SConstruct index e555de8e81..ea91b38814 100644 --- a/SConstruct +++ b/SConstruct @@ -210,12 +210,12 @@ add_option( "cxx-use-shell-environment", "use $CXX from shell for C++ compiler" add_option( "ld", "linker to use" , 1 , True ) add_option( "c++11", "enable c++11 support (experimental)", 0, True ) -add_option( "cpppath", "Include path if you have headers in a nonstandard directory" , 1 , True ) -add_option( "libpath", "Library path if you have libraries in a nonstandard directory" , 1 , True ) +add_option( "cpppath", "Include path if you have headers in a nonstandard directory" , 1 , False ) +add_option( "libpath", "Library path if you have libraries in a nonstandard directory" , 1 , False ) -add_option( "extrapath", "comma separated list of add'l paths (--extrapath /opt/foo/,/foo) static linking" , 1 , True ) -add_option( "extrapathdyn", "comma separated list of add'l paths (--extrapath /opt/foo/,/foo) dynamic linking" , 1 , True ) -add_option( "extralib", "comma separated list of libraries (--extralib js_static,readline" , 1 , True ) +add_option( "extrapath", "comma separated list of add'l paths (--extrapath /opt/foo/,/foo) static linking" , 1 , False ) +add_option( "extrapathdyn", "comma separated list of add'l paths (--extrapath /opt/foo/,/foo) dynamic linking" , 1 , False ) +add_option( "extralib", "comma separated list of libraries (--extralib js_static,readline" , 1 , False ) add_option( "no-glibc-check" , "don't check for new versions of glibc" , 0 , False ) diff --git a/src/mongo/base/error_codes.err b/src/mongo/base/error_codes.err index 0e84bf0d34..72710f426d 100644 --- a/src/mongo/base/error_codes.err +++ b/src/mongo/base/error_codes.err @@ -84,9 +84,11 @@ error_code("NoClientContext", 81) error_code("NoProgressMade", 82) # Non-sequential error codes (for compatibility only) -error_code("DuplicateKey", 11000) error_code("NotMaster", 10107) #this comes from assert_util.h +error_code("DuplicateKey", 11000) +error_code("InterruptedAtShutdown", 11600) error_code("Interrupted", 11601) error_code("OutOfDiskSpace", 14031 ) error_class("NetworkError", ["HostUnreachable", "HostNotFound"]) +error_class("Interruption", ["Interrupted", "InterruptedAtShutdown", "ExceededTimeLimit"]) diff --git a/src/mongo/base/generate_error_codes.py b/src/mongo/base/generate_error_codes.py index 19330d1ff5..eee41afce2 100644 --- a/src/mongo/base/generate_error_codes.py +++ b/src/mongo/base/generate_error_codes.py @@ -158,6 +158,8 @@ def generate_error_class_predicate_definition(class_name, code_names): #pragma once +#include + #include "mongo/base/string_data.h" #include "mongo/client/export_macros.h" @@ -177,19 +179,19 @@ class MONGO_CLIENT_API ErrorCodes { MaxError }; - static const char* errorString(Error err); + static std::string errorString(Error err); /** - * Parse an Error from its "name". Returns UnknownError if "name" is unrecognized. + * Parses an Error from its "name". Returns UnknownError if "name" is unrecognized. * * NOTE: Also returns UnknownError for the string "UnknownError". */ static Error fromString(const StringData& name); /** - * Parse an Error from its "code". Returns UnknownError if "code" is unrecognized. - * - * NOTE: Also returns UnknownError for the integer code for UnknownError. + * Casts an integer "code" to an Error. Unrecognized codes are preserved, meaning + * that the result of a call to fromInt() may not be one of the values in the + * Error enumeration. */ static Error fromInt(int code); @@ -218,13 +220,16 @@ class MONGO_CLIENT_API ErrorCodes { #include "mongo/base/error_codes.h" -#include +#include + +#include "mongo/util/mongoutils/str.h" namespace mongo { - const char* ErrorCodes::errorString(Error err) { + + std::string ErrorCodes::errorString(Error err) { switch (err) { %(symbol_to_string_cases)s; - default: return "Unknown error code"; + default: return mongoutils::str::stream() << "Location" << err; } } @@ -234,14 +239,14 @@ class MONGO_CLIENT_API ErrorCodes { } ErrorCodes::Error ErrorCodes::fromInt(int code) { - switch (code) { - %(int_to_symbol_cases)s; - default: - return UnknownError; - } + return static_cast(code); } %(error_code_class_predicate_definitions)s + +namespace { + BOOST_STATIC_ASSERT(sizeof(ErrorCodes::Error) == sizeof(int)); +} // namespace } // namespace mongo ''' diff --git a/src/mongo/base/status-inl.h b/src/mongo/base/status-inl.h index 22679707b6..add962e236 100644 --- a/src/mongo/base/status-inl.h +++ b/src/mongo/base/status-inl.h @@ -45,7 +45,7 @@ namespace mongo { return _error ? _error->code : ErrorCodes::OK; } - inline const char* Status::codeString() const { + inline std::string Status::codeString() const { return ErrorCodes::errorString(code()); } diff --git a/src/mongo/base/status.h b/src/mongo/base/status.h index 275cb767e5..ad301f8b00 100644 --- a/src/mongo/base/status.h +++ b/src/mongo/base/status.h @@ -89,7 +89,7 @@ namespace mongo { inline ErrorCodes::Error code() const; - inline const char* codeString() const; + inline std::string codeString() const; inline std::string reason() const; diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index a42d7a45f3..376584e64e 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -31,7 +31,6 @@ namespace mongo { enum CommonErrorCodes { OkCode = 0, DatabaseDifferCaseCode = 13297 , // uassert( 13297 ) - InterruptedAtShutdown = 11600 , // uassert( 11600 ) SendStaleConfigCode = 13388 , // uassert( 13388 ) RecvStaleConfigCode = 9996, // uassert( 9996 ) PrepareConfigsFailedCode = 13104, // uassert( 13104 ) @@ -144,12 +143,6 @@ namespace mongo { virtual bool severe() const { return true; } virtual bool isUserAssertion() const { return false; } - - /* true if an interrupted exception - see KillCurrentOp */ - bool interrupted() { - return _ei.code == InterruptedAtShutdown || _ei.code == 11601 || - _ei.code == ErrorCodes::ExceededTimeLimit; - } }; /* UserExceptions are valid errors that a user can cause, like out of disk space or duplicate key */ diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp index c79581b7e8..d8f3c77734 100644 --- a/src/mongo/util/version.cpp +++ b/src/mongo/util/version.cpp @@ -31,7 +31,7 @@ namespace mongo { * 1.2.3-rc4-pre- * If you really need to do something else you'll need to fix _versionArray() */ - const char versionString[] = "2.6.0-rc0"; + const char versionString[] = "2.6.0-rc1"; // See unit test for example outputs BSONArray toVersionArray(const char* version){