diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-05-17 16:45:01 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-05-23 09:24:10 -0400 |
commit | 017f8b201baffabbd8a66f278a4fbcaf8baced79 (patch) | |
tree | d9353331d6960a42413f7a278d458d09ef65997a | |
parent | 02327e0ff4c1cfc33f36fa816f9ba63688e68248 (diff) | |
download | mongo-017f8b201baffabbd8a66f278a4fbcaf8baced79.tar.gz |
SERVER-41220 Avoid WT include if unavailable
-rw-r--r-- | src/mongo/rpc/SConscript | 10 | ||||
-rw-r--r-- | src/mongo/rpc/op_msg.cpp | 12 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/mongo/rpc/SConscript b/src/mongo/rpc/SConscript index af84d991ab1..b195aa6534e 100644 --- a/src/mongo/rpc/SConscript +++ b/src/mongo/rpc/SConscript @@ -1,6 +1,8 @@ # -*- mode: python -*- Import("env") +Import("wiredtiger") +Import("get_option") env = env.Clone() @@ -19,7 +21,11 @@ env.Library( ], ) -env.Library( +protoEnv = env.Clone() +if wiredtiger: + protoEnv.InjectThirdParty(libraries=['wiredtiger']) + +protoEnv.Library( target=[ 'protocol', ], @@ -36,7 +42,7 @@ env.Library( '$BUILD_DIR/mongo/bson/util/bson_extract', '$BUILD_DIR/mongo/db/bson/dotted_path_support', '$BUILD_DIR/mongo/db/server_options_core', - '$BUILD_DIR/third_party/wiredtiger/wiredtiger_checksum', + '$BUILD_DIR/third_party/wiredtiger/wiredtiger_checksum' if wiredtiger else [], ], ) diff --git a/src/mongo/rpc/op_msg.cpp b/src/mongo/rpc/op_msg.cpp index d6dcad993c7..1f6cee46f75 100644 --- a/src/mongo/rpc/op_msg.cpp +++ b/src/mongo/rpc/op_msg.cpp @@ -37,12 +37,16 @@ #include <set> #include "mongo/base/data_type_endian.h" +#include "mongo/config.h" #include "mongo/db/bson/dotted_path_support.h" #include "mongo/rpc/object_check.h" #include "mongo/util/bufreader.h" #include "mongo/util/hex.h" #include "mongo/util/log.h" -#include "third_party/wiredtiger/wiredtiger.h" + +#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED +#include <wiredtiger.h> +#endif namespace mongo { namespace { @@ -61,6 +65,7 @@ enum class Section : uint8_t { constexpr int kCrc32Size = 4; +#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED // All fields including size, requestId, and responseTo must already be set. The size must already // include the final 4-byte checksum. uint32_t calculateChecksum(const Message& message) { @@ -71,6 +76,7 @@ uint32_t calculateChecksum(const Message& message) { invariant(OpMsg::isFlagSet(message, OpMsg::kChecksumPresent)); return wiredtiger_crc32c_func()(message.singleData().view2ptr(), message.size() - kCrc32Size); } +#endif // MONGO_CONFIG_WIREDTIGER_ENABLED } // namespace uint32_t OpMsg::flags(const Message& message) { @@ -97,6 +103,7 @@ uint32_t OpMsg::getChecksum(const Message& message) { } void OpMsg::appendChecksum(Message* message) { +#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED if (message->operation() != dbMsg) { return; } @@ -112,6 +119,7 @@ void OpMsg::appendChecksum(Message* message) { message->header().setLen(newSize); DataView(message->singleData().view2ptr() + newSize - kCrc32Size) .write<LittleEndian<uint32_t>>(calculateChecksum(*message)); +#endif } OpMsg OpMsg::parse(const Message& message) try { @@ -189,11 +197,13 @@ OpMsg OpMsg::parse(const Message& message) try { !inBody); } +#ifdef MONGO_CONFIG_WIREDTIGER_ENABLED if (haveChecksum) { uassert(ErrorCodes::ChecksumMismatch, "OP_MSG checksum does not match contents", OpMsg::getChecksum(message) == calculateChecksum(message)); } +#endif return msg; } catch (const DBException& ex) { |