summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBen Caimano <ben.caimano@10gen.com>2020-12-08 22:01:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-17 20:15:36 +0000
commit2f850341d371f332a54c6d03d53641d4e328074a (patch)
treeb7a84bbc8db5f1e080e014d99f672a5907e91ad3 /src/mongo/db
parent537641adca3ef2134c11322637b6bc4723af7611 (diff)
downloadmongo-2f850341d371f332a54c6d03d53641d4e328074a.tar.gz
SERVER-53269 Use ClientStrand to bind Client temporarily in op_msg_fuzzer
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/op_msg_fuzzer.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mongo/db/op_msg_fuzzer.cpp b/src/mongo/db/op_msg_fuzzer.cpp
index db0dc48ddaa..e850bd9e3fd 100644
--- a/src/mongo/db/op_msg_fuzzer.cpp
+++ b/src/mongo/db/op_msg_fuzzer.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/auth/authz_manager_external_state_local.h"
#include "mongo/db/auth/authz_manager_external_state_mock.h"
#include "mongo/db/client.h"
+#include "mongo/db/client_strand.h"
#include "mongo/db/logical_time.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_client_info.h"
@@ -49,7 +50,7 @@
extern "C" int LLVMFuzzerTestOneInput(const char* Data, size_t Size) {
static mongo::ServiceContext* serviceContext;
- static mongo::ServiceContext::UniqueClient client;
+ static mongo::ClientStrandPtr clientStrand;
static mongo::transport::TransportLayerMock transportLayer;
static mongo::transport::SessionHandle session;
static std::unique_ptr<mongo::AuthzManagerExternalStateMock> localExternalState;
@@ -71,8 +72,7 @@ extern "C" int LLVMFuzzerTestOneInput(const char* Data, size_t Size) {
serviceContext = mongo::getGlobalServiceContext();
serviceContext->setServiceEntryPoint(
std::make_unique<mongo::ServiceEntryPointMongod>(serviceContext));
- client = serviceContext->makeClient("test", session);
- // opCtx = serviceContext->makeOperationContext(client.get());
+ clientStrand = mongo::ClientStrand::make(serviceContext->makeClient("test", session));
localExternalState = std::make_unique<mongo::AuthzManagerExternalStateMock>();
externalState = localExternalState.get();
@@ -95,8 +95,9 @@ extern "C" int LLVMFuzzerTestOneInput(const char* Data, size_t Size) {
if (Size < sizeof(mongo::MSGHEADER::Value)) {
return 0;
}
- mongo::ServiceContext::UniqueOperationContext opCtx =
- serviceContext->makeOperationContext(client.get());
+
+ auto clientGuard = clientStrand->bind();
+ auto opCtx = serviceContext->makeOperationContext(clientGuard.get());
mongo::VectorClockMutable::get(serviceContext)->tickClusterTimeTo(kInMemoryLogicalTime);
int new_size = Size + sizeof(int);
@@ -106,8 +107,6 @@ extern "C" int LLVMFuzzerTestOneInput(const char* Data, size_t Size) {
mongo::Message msg(std::move(sb));
try {
- // TODO SERVER-51278: Replace `AlternativeClientRegion` with `ClientStrand`.
- mongo::AlternativeClientRegion acr(client);
serviceContext->getServiceEntryPoint()->handleRequest(opCtx.get(), msg).get();
} catch (const mongo::AssertionException&) {
// We need to catch exceptions caused by invalid inputs