From: Kefu Chai Date: Fri, 7 Jul 2017 05:44:03 +0000 (+0800) Subject: common/Timer: do not add event if already shutdown X-Git-Tag: v12.1.1~139^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8c8220c39cf82b6d4b2387de4c3289a5e4fd3ad9;p=ceph.git 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 --- diff --git a/src/common/Timer.cc b/src/common/Timer.cc index ef76a9e41b7d..82e090148f3b 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);