From: Jason Dillaman Date: Wed, 13 Apr 2016 14:34:24 +0000 (-0400) Subject: journal: race possible when re-watching a journal object X-Git-Tag: ses3-milestone4~17^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=877d44bcd0dd4f7177eca0c96dba2a2df546a493;p=ceph.git journal: race possible when re-watching a journal object Signed-off-by: Jason Dillaman --- diff --git a/src/journal/ObjectPlayer.cc b/src/journal/ObjectPlayer.cc index b135d39bfac5..894b56f5da2d 100644 --- a/src/journal/ObjectPlayer.cc +++ b/src/journal/ObjectPlayer.cc @@ -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(); }