]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: handle unregistering the image watcher when disconnected
authorJason Dillaman <dillaman@redhat.com>
Mon, 14 Mar 2016 15:34:04 +0000 (11:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Mon, 14 Mar 2016 16:15:46 +0000 (12:15 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageWatcher.cc

index 2bd3c0a61cb7abcd01c4ac9fff9cc25537d968b2..ebc43ad3e71db61fb77374666fc93dba44c1657f 100644 (file)
@@ -123,14 +123,20 @@ void ImageWatcher::unregister_watch(Context *on_finish) {
   {
     RWLock::WLocker l(m_watch_lock);
     if (m_watch_state == WATCH_STATE_REGISTERED) {
+      m_watch_state = WATCH_STATE_UNREGISTERED;
+
       librados::AioCompletion *aio_comp = create_rados_safe_callback(
         new C_UnwatchAndFlush(m_image_ctx.md_ctx, on_finish));
       int r = m_image_ctx.md_ctx.aio_unwatch(m_watch_handle, aio_comp);
       assert(r == 0);
       aio_comp->release();
+      return;
+    } else if (m_watch_state == WATCH_STATE_ERROR) {
+      m_watch_state = WATCH_STATE_UNREGISTERED;
     }
-    m_watch_state = WATCH_STATE_UNREGISTERED;
   }
+
+  on_finish->complete(0);
 }
 
 void ImageWatcher::flush(Context *on_finish) {