diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2020-10-20 12:07:07 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-23 01:32:03 +0000 |
commit | a730e454f65fd41dd8526c56946c67a05e9f8f7d (patch) | |
tree | cd3f112b4fe551d83a986049af3879ef9cfa80b5 /src/mongo/client/dbclient_base.h | |
parent | 1720ada5cf4ece8473a60f4515e12f1b181a7335 (diff) | |
download | mongo-a730e454f65fd41dd8526c56946c67a05e9f8f7d.tar.gz |
SERVER-51743 Fix query operator for regex in cloner utils. SERVER-51744 Fix the filter for OplogFetcher::_makeFindQuery(). SERVER-51746 Fix the application name for tenant migration recipient collection cloner & oplog fetcher DBClientConnection. SERVER-51745 Set setRequestMetadataWriter() for tenant collection cloner.
Diffstat (limited to 'src/mongo/client/dbclient_base.h')
-rw-r--r-- | src/mongo/client/dbclient_base.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mongo/client/dbclient_base.h b/src/mongo/client/dbclient_base.h index 19bf9d2c417..a9dbe457a84 100644 --- a/src/mongo/client/dbclient_base.h +++ b/src/mongo/client/dbclient_base.h @@ -852,4 +852,34 @@ private: BSONElement getErrField(const BSONObj& result); bool hasErrField(const BSONObj& result); +/* + * RAII-style class to set new RequestMetadataWriter and ReplyMetadataReader on DBClientConnection + * "_conn". On object destruction, '_conn' is set back to it's old RequestsMetadataWriter and + * ReplyMetadataReader. + */ +class ScopedMetadataWriterAndReader { + ScopedMetadataWriterAndReader(const ScopedMetadataWriterAndReader&) = delete; + ScopedMetadataWriterAndReader& operator=(const ScopedMetadataWriterAndReader&) = delete; + +public: + ScopedMetadataWriterAndReader(DBClientBase* conn, + rpc::RequestMetadataWriter writer, + rpc::ReplyMetadataReader reader) + : _conn(conn), + _oldWriter(std::move(conn->getRequestMetadataWriter())), + _oldReader(std::move(conn->getReplyMetadataReader())) { + _conn->setRequestMetadataWriter(std::move(writer)); + _conn->setReplyMetadataReader(std::move(reader)); + } + ~ScopedMetadataWriterAndReader() { + _conn->setRequestMetadataWriter(std::move(_oldWriter)); + _conn->setReplyMetadataReader(std::move(_oldReader)); + } + +private: + DBClientBase* const _conn; // not owned. + rpc::RequestMetadataWriter _oldWriter; + rpc::ReplyMetadataReader _oldReader; +}; + } // namespace mongo |