]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: pass pool watcher image ids by rvalue
authorJason Dillaman <dillaman@redhat.com>
Tue, 25 Apr 2017 01:55:12 +0000 (21:55 -0400)
committerJason Dillaman <dillaman@redhat.com>
Thu, 27 Apr 2017 19:54:12 +0000 (15:54 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/test_PoolWatcher.cc
src/test/rbd_mirror/test_mock_PoolWatcher.cc
src/tools/rbd_mirror/PoolReplayer.cc
src/tools/rbd_mirror/PoolReplayer.h
src/tools/rbd_mirror/PoolWatcher.cc
src/tools/rbd_mirror/PoolWatcher.h

index 9d11c715638ba27a54457b20609ea51f2f518e2b..c12724669330128fe4ec47c95ffee44e2bb383ce 100644 (file)
@@ -76,8 +76,8 @@ public:
     }
 
     void handle_update(const std::string &mirror_uuid,
-                       const ImageIds &added_image_ids,
-                       const ImageIds &removed_image_ids) override {
+                       ImageIds &&added_image_ids,
+                       ImageIds &&removed_image_ids) override {
       Mutex::Locker locker(test->m_lock);
       for (auto &image_id : removed_image_ids) {
         image_ids.erase(image_id);
index b6e61516dce7c7fc466e426869a50b249af2db10..1b7877434ad96bb24a59fbd45bc5d0dd0d8bb8b1 100644 (file)
@@ -163,8 +163,13 @@ public:
     MockListener(TestMockPoolWatcher *test) : test(test) {
     }
 
-    MOCK_METHOD3(handle_update, void(const std::string &, const ImageIds &,
-                                     const ImageIds &));
+    MOCK_METHOD3(mock_handle_update, void(const std::string &, const ImageIds &,
+                                          const ImageIds &));
+    void handle_update(const std::string &mirror_uuid,
+                       ImageIds &&added_image_ids,
+                       ImageIds &&removed_image_ids) override {
+      mock_handle_update(mirror_uuid, added_image_ids, removed_image_ids);
+    }
   };
 
   TestMockPoolWatcher() : m_lock("TestMockPoolWatcher::m_lock") {
@@ -208,8 +213,8 @@ public:
                                      const std::string &mirror_uuid,
                                      const ImageIds &added_image_ids,
                                      const ImageIds &removed_image_ids) {
-    EXPECT_CALL(mock_listener, handle_update(mirror_uuid, added_image_ids,
-                                             removed_image_ids))
+    EXPECT_CALL(mock_listener, mock_handle_update(mirror_uuid, added_image_ids,
+                                                  removed_image_ids))
       .WillOnce(WithoutArgs(Invoke([this]() {
           Mutex::Locker locker(m_lock);
           ++m_update_count;
index 6747ddc15aacb30d3c4d421e2487ef51abb5c021..e95b19c97ff32088573fcb28fdfc2e4dd08ba4ac 100644 (file)
@@ -551,8 +551,8 @@ void PoolReplayer::release_leader()
 }
 
 void PoolReplayer::handle_update(const std::string &mirror_uuid,
-                                const ImageIds &added_image_ids,
-                                const ImageIds &removed_image_ids) {
+                                ImageIds &&added_image_ids,
+                                ImageIds &&removed_image_ids) {
   assert(!mirror_uuid.empty());
   if (m_stopping.read()) {
     return;
index 7de10a5c6a5e56d66c13169bb27f2b7a2e277b71..526ed536c0fa3265a34ee3a38bbcb81bc9d953ea 100644 (file)
@@ -69,18 +69,18 @@ private:
     }
 
     void handle_update(const std::string &mirror_uuid,
-                       const ImageIds &added_image_ids,
-                       const ImageIds &removed_image_ids) override {
-      pool_replayer->handle_update(mirror_uuid, added_image_ids,
-                                  removed_image_ids);
+                       ImageIds &&added_image_ids,
+                       ImageIds &&removed_image_ids) override {
+      pool_replayer->handle_update(mirror_uuid, std::move(added_image_ids),
+                                  std::move(removed_image_ids));
     }
   };
 
   struct C_RefreshLocalImages;
 
   void handle_update(const std::string &mirror_uuid,
-                     const ImageIds &added_image_ids,
-                     const ImageIds &removed_image_ids);
+                     ImageIds &&added_image_ids,
+                     ImageIds &&removed_image_ids);
 
   int init_rados(const std::string &cluster_name,
                  const std::string &client_name,
index 6a855ff2185309a2fb1381eb18f1c0d4a59ee2cf..18c6df3840fb948d863d1277db66d7baddd455bb 100644 (file)
@@ -479,7 +479,7 @@ void PoolWatcher<I>::notify_listener() {
   }
 
   if (!removed_image_ids.empty()) {
-    m_listener.handle_update(mirror_uuid, {}, removed_image_ids);
+    m_listener.handle_update(mirror_uuid, {}, std::move(removed_image_ids));
     removed_image_ids.clear();
   }
 
@@ -529,7 +529,8 @@ void PoolWatcher<I>::notify_listener() {
     mirror_uuid = m_mirror_uuid;
   }
 
-  m_listener.handle_update(mirror_uuid, added_image_ids, removed_image_ids);
+  m_listener.handle_update(mirror_uuid, std::move(added_image_ids),
+                           std::move(removed_image_ids));
 
   {
     Mutex::Locker locker(m_lock);
index aebd981b864530d4b4077cd87aae112eba6ed728..aec063b3e7c3cbc3c1fdeebd5d5305ff13d1169d 100644 (file)
@@ -37,8 +37,8 @@ public:
     }
 
     virtual void handle_update(const std::string &mirror_uuid,
-                               const ImageIds &added_image_ids,
-                               const ImageIds &removed_image_ids) = 0;
+                               ImageIds &&added_image_ids,
+                               ImageIds &&removed_image_ids) = 0;
   };
 
   PoolWatcher(Threads<ImageCtxT> *threads, librados::IoCtx &remote_io_ctx,