summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Wangensteen <george.wangensteen@mongodb.com>2021-06-08 22:29:40 +0000
committerGeorge Wangensteen <george.wangensteen@mongodb.com>2021-06-23 14:53:17 +0000
commit0a1b34e2da06434d3fe7874575356c5be5cabaf9 (patch)
tree20793d18ea550303b9f71a648ca0389298df91a3
parentbaa350cb285592702833f4f51ecc7ffbb5982080 (diff)
downloadmongo-0a1b34e2da06434d3fe7874575356c5be5cabaf9.tar.gz
SERVER-54510 Ensure client is bound to thread destroying opCtx in transport tests
(cherry picked from commit 89ed94739e87e5378f663c196a16790feb95abb3)
-rw-r--r--src/mongo/transport/service_state_machine_test.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mongo/transport/service_state_machine_test.cpp b/src/mongo/transport/service_state_machine_test.cpp
index afd55f05549..cae5c81e41d 100644
--- a/src/mongo/transport/service_state_machine_test.cpp
+++ b/src/mongo/transport/service_state_machine_test.cpp
@@ -38,6 +38,7 @@
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/db/client.h"
+#include "mongo/db/client_strand.h"
#include "mongo/db/dbmessage.h"
#include "mongo/db/service_context.h"
#include "mongo/db/service_context_test_fixture.h"
@@ -536,9 +537,15 @@ public:
Future<DbResponse> handleRequest(OperationContext* opCtx,
const Message& request) noexcept override {
- return ExecutorFuture<void>(_fixture->_threadPool)
- .then([this, opCtx, request] { return _fixture->_handleRequest(opCtx, request); })
- .unsafeToInlineFuture();
+ auto [p, f] = makePromiseFuture<DbResponse>();
+ ExecutorFuture<void>(_fixture->_threadPool)
+ .then([this, opCtx, &request, p = std::move(p)]() mutable {
+ auto strand = ClientStrand::get(opCtx->getClient());
+ strand->run(
+ [&] { p.setWith([&] { return _fixture->_handleRequest(opCtx, request); }); });
+ })
+ .getAsync([](auto) {});
+ return std::move(f);
}
void onEndSession(const transport::SessionHandle& session) override {