]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rbd-mirror: pool watcher registration error might result in race 36479/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 5 Aug 2020 16:36:26 +0000 (12:36 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 5 Aug 2020 16:36:26 +0000 (12:36 -0400)
The init finish context should be swapped out before it attempts to
re-register the watcher. This affects the test case which mocks the
timer to fire immediately instead of after 30 seconds.

Fixes: https://tracker.ceph.com/issues/46669
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/PoolWatcher.cc

index c6d68ecd4e1c9c77b676178a82fd52994293d3c0..c3346dad11038f8a378c9871608885417c97310e 100644 (file)
@@ -178,10 +178,12 @@ void PoolWatcher<I>::handle_register_watcher(int r) {
     std::swap(on_init_finish, m_on_init_finish);
   } else if (r == -ENOENT) {
     dout(5) << "mirroring directory does not exist" << dendl;
-    schedule_refresh_images(30);
+    {
+      std::lock_guard locker{m_lock};
+      std::swap(on_init_finish, m_on_init_finish);
+    }
 
-    std::lock_guard locker{m_lock};
-    std::swap(on_init_finish, m_on_init_finish);
+    schedule_refresh_images(30);
   } else {
     derr << "unexpected error registering mirroring directory watch: "
          << cpp_strerror(r) << dendl;