From 877d44bcd0dd4f7177eca0c96dba2a2df546a493 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 13 Apr 2016 10:34:24 -0400 Subject: [PATCH] journal: race possible when re-watching a journal object Signed-off-by: Jason Dillaman --- src/journal/ObjectPlayer.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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(); } -- 2.47.3