From 8c8220c39cf82b6d4b2387de4c3289a5e4fd3ad9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 7 Jul 2017 13:44:03 +0800 Subject: [PATCH] common/Timer: do not add event if already shutdown otherwise the callback is leaked. Fixes: http://tracker.ceph.com/issues/20432 Signed-off-by: Kefu Chai --- src/common/Timer.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/Timer.cc b/src/common/Timer.cc index ef76a9e41b7..82e090148f3 100644 --- a/src/common/Timer.cc +++ b/src/common/Timer.cc @@ -126,8 +126,11 @@ void SafeTimer::add_event_after(double seconds, Context *callback) void SafeTimer::add_event_at(utime_t when, Context *callback) { assert(lock.is_locked()); - ldout(cct,10) << "add_event_at " << when << " -> " << callback << dendl; - + ldout(cct,10) << __func__ << " " << when << " -> " << callback << dendl; + if (stopping) { + ldout(cct,5) << __func__ << " already shutdown, event not added" << dendl; + delete callback; + } scheduled_map_t::value_type s_val(when, callback); scheduled_map_t::iterator i = schedule.insert(s_val); -- 2.39.5