From: Mykola Golub Date: Wed, 24 Apr 2019 14:08:48 +0000 (+0100) Subject: librbd: leak on canceling simple io scheduler timer task X-Git-Tag: v15.1.0~2824^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27755%2Fhead;p=ceph.git librbd: leak on canceling simple io scheduler timer task When the timer task is canceled it is just deleted and the passed context will not be executed. Signed-off-by: Mykola Golub --- diff --git a/src/librbd/io/SimpleSchedulerObjectDispatch.cc b/src/librbd/io/SimpleSchedulerObjectDispatch.cc index 21f8fe5f5cf0..49dd68483a38 100644 --- a/src/librbd/io/SimpleSchedulerObjectDispatch.cc +++ b/src/librbd/io/SimpleSchedulerObjectDispatch.cc @@ -499,20 +499,19 @@ void SimpleSchedulerObjectDispatch::schedule_dispatch_delayed_requests() { object_requests = m_dispatch_queue.front().get(); } - auto ctx = new FunctionContext( - [this, object_no=object_requests->get_object_no()](int r) { - Mutex::Locker locker(m_lock); - dispatch_delayed_requests(object_no); - }); - m_timer_task = new FunctionContext( - [this, ctx](int r) { + [this, object_no=object_requests->get_object_no()](int r) { ceph_assert(m_timer_lock->is_locked()); auto cct = m_image_ctx->cct; ldout(cct, 20) << "running timer task " << m_timer_task << dendl; m_timer_task = nullptr; - m_image_ctx->op_work_queue->queue(ctx, 0); + m_image_ctx->op_work_queue->queue( + new FunctionContext( + [this, object_no](int r) { + Mutex::Locker locker(m_lock); + dispatch_delayed_requests(object_no); + }), 0); }); ldout(cct, 20) << "scheduling task " << m_timer_task << " at "