0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-19001 Eliminate unnecessary potential race in the CallbackHandleComparsion executor unit test.

The test as previously written has a race condition if the executor is allowed
to execute multiple callbacks concurrently, since both completion callbacks set
the same status object. However, for this test, there is no need for them to set
the same status object.
This commit is contained in:
Andy Schwerin 2015-07-01 15:15:17 -04:00
parent a816f73752
commit 7ec946113a

View File

@ -450,14 +450,15 @@ COMMON_EXECUTOR_TEST(RemoteCommandWithTimeout) {
COMMON_EXECUTOR_TEST(CallbackHandleComparison) {
TaskExecutor& executor = getExecutor();
Status status(ErrorCodes::InternalError, "");
auto status1 = getDetectableErrorStatus();
auto status2 = getDetectableErrorStatus();
const RemoteCommandRequest request(HostAndPort("lazy", 27017), "admin", BSON("cmd" << 1));
TaskExecutor::CallbackHandle cbHandle1 = unittest::assertGet(executor.scheduleRemoteCommand(
request,
stdx::bind(setStatusOnRemoteCommandCompletion, stdx::placeholders::_1, request, &status)));
stdx::bind(setStatusOnRemoteCommandCompletion, stdx::placeholders::_1, request, &status1)));
TaskExecutor::CallbackHandle cbHandle2 = unittest::assertGet(executor.scheduleRemoteCommand(
request,
stdx::bind(setStatusOnRemoteCommandCompletion, stdx::placeholders::_1, request, &status)));
stdx::bind(setStatusOnRemoteCommandCompletion, stdx::placeholders::_1, request, &status2)));
// test equality
ASSERT_TRUE(cbHandle1 == cbHandle1);