diff options
author | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-14 17:46:22 +0000 |
---|---|---|
committer | Bernard Gorman <bernard.gorman@gmail.com> | 2018-03-15 17:33:50 +0000 |
commit | 5ecf2c0a5bffa837c96ad20dea23a94c5165739a (patch) | |
tree | 254b1baa62ecd3092b8962778fcc0480c066de03 /src/mongo/rpc/metadata/client_metadata.cpp | |
parent | 8c639f958eb5edff4d52560e4c3dfe04c7a78f31 (diff) | |
download | mongo-5ecf2c0a5bffa837c96ad20dea23a94c5165739a.tar.gz |
SERVER-18094 Add 'localOps' parameter to $currentOp to show local mongoS operations
Diffstat (limited to 'src/mongo/rpc/metadata/client_metadata.cpp')
-rw-r--r-- | src/mongo/rpc/metadata/client_metadata.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mongo/rpc/metadata/client_metadata.cpp b/src/mongo/rpc/metadata/client_metadata.cpp index adcb3711b71..eebf1b6d9dc 100644 --- a/src/mongo/rpc/metadata/client_metadata.cpp +++ b/src/mongo/rpc/metadata/client_metadata.cpp @@ -306,9 +306,26 @@ void ClientMetadata::setMongoSMetadata(StringData hostAndPort, sub.append(kVersion, version); } - _document = builder.obj(); -} + auto document = builder.obj(); + + if (!_appName.empty()) { + // The _appName field points into the existing _document, which we are about to replace. + // We must redirect _appName to point into the new doc *before* replacing the old doc. We + // expect the 'application' metadata of the new document to be identical to the old. + auto appMetaData = document[kApplication]; + invariant(appMetaData.isABSONObj()); + + auto appNameEl = appMetaData[kName]; + invariant(appNameEl.type() == BSONType::String); + + auto appName = appNameEl.valueStringData(); + invariant(appName == _appName); + _appName = appName; + } + + _document = std::move(document); +} void ClientMetadata::serialize(StringData driverName, StringData driverVersion, |