The std::conditional_variable will keep the provided reference and
repeatedly dereference it even after the lock was dropped and
re-acquired. This can lead to an invalid read if the associated
schedule entry has been removed while waiting.
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
if (schedule.empty()) {
cond.wait(l);
} else {
- cond.wait_until(l, schedule.begin()->first);
+ auto when = schedule.begin()->first;
+ cond.wait_until(l, when);
}
ldout(cct,20) << "timer_thread awake" << dendl;
}