]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: race possible when re-watching a journal object 8494/head
authorJason Dillaman <dillaman@redhat.com>
Wed, 13 Apr 2016 14:34:24 +0000 (10:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 13 Apr 2016 14:34:24 +0000 (10:34 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/journal/ObjectPlayer.cc

index b135d39bfac5fce77bd3e94ea1d39ea0e387f237..894b56f5da2da1d77450d6656fd36d9dca13c951 100644 (file)
@@ -65,7 +65,10 @@ void ObjectPlayer::watch(Context *on_fetch, double interval) {
   assert(m_watch_ctx == NULL);
   m_watch_ctx = on_fetch;
 
-  schedule_watch();
+  // watch callback might lead to re-scheduled watch
+  if (!m_watch_in_progress) {
+    schedule_watch();
+  }
 }
 
 void ObjectPlayer::unwatch() {
@@ -202,6 +205,7 @@ void ObjectPlayer::handle_watch_task() {
   ldout(m_cct, 10) << __func__ << ": " << m_oid << " polling" << dendl;
   assert(m_watch_ctx != NULL);
 
+  assert(!m_watch_in_progress);
   m_watch_in_progress = true;
   m_watch_task = NULL;
   fetch(new C_WatchFetch(this));
@@ -227,6 +231,13 @@ void ObjectPlayer::handle_watch_fetched(int r) {
 
   {
     Mutex::Locker locker(m_timer_lock);
+    assert(m_watch_in_progress);
+
+    // callback might have attempted to re-schedule the watch -- complete now
+    if (m_watch_ctx != nullptr) {
+      schedule_watch();
+    }
+
     m_watch_in_progress = false;
     m_watch_in_progress_cond.Signal();
   }