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() {
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));
{
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();
}