]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rbd_mirror: grab timer lock before calling add_event_after() 45905/head
authorIlya Dryomov <idryomov@gmail.com>
Wed, 13 Apr 2022 13:24:04 +0000 (15:24 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 14 Apr 2022 08:21:49 +0000 (10:21 +0200)
add_event_after() expects an externally provided mutex to be held
for the call.  This was missed in commit 8965a0f2a6f7 ("rbd-mirror:
synchronize with in-flight stop in ImageReplayer::stop()").

Fixes: https://tracker.ceph.com/issues/55317
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 60e16106837e0d23366709f70f39c4f1ae7a2a45)

src/test/rbd_mirror/test_mock_ImageReplayer.cc

index c19d4923ab9626b5b5ebe705df67e91ce043ed68..177b71a158484989bbfec725180fa086f3613513 100644 (file)
@@ -880,6 +880,7 @@ TEST_F(TestMockImageReplayer, StopJoinInterruptedReplayer) {
   const double DELAY = 10;
   EXPECT_CALL(mock_replayer, shut_down(_))
     .WillOnce(Invoke([this, DELAY](Context* ctx) {
+               std::lock_guard l(m_threads->timer_lock);
                m_threads->timer->add_event_after(DELAY, ctx);
               }));
   EXPECT_CALL(mock_replayer, destroy());
@@ -927,6 +928,7 @@ TEST_F(TestMockImageReplayer, StopJoinRequestedStop) {
   const double DELAY = 10;
   EXPECT_CALL(mock_replayer, shut_down(_))
     .WillOnce(Invoke([this, DELAY](Context* ctx) {
+               std::lock_guard l(m_threads->timer_lock);
                m_threads->timer->add_event_after(DELAY, ctx);
               }));
   EXPECT_CALL(mock_replayer, destroy());