From 32a3b85a0c7c51e8aca2f03c33f400dbab46e63e Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Wed, 24 Apr 2019 15:08:48 +0100 Subject: [PATCH] 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 --- src/librbd/io/SimpleSchedulerObjectDispatch.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 " -- 2.47.3