From 01f38cc9c15bb6875dae647c5c67e372182020e7 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Mon, 17 Dec 2018 19:54:14 +0000 Subject: [PATCH] Fix: crash while destructing crmorch Signed-off-by: Qi Luo --- orchagent/crmorch.cpp | 3 ++- orchagent/crmorch.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/orchagent/crmorch.cpp b/orchagent/crmorch.cpp index 56f7e5bb38..a590445c5b 100644 --- a/orchagent/crmorch.cpp +++ b/orchagent/crmorch.cpp @@ -165,7 +165,8 @@ CrmOrch::CrmOrch(DBConnector *db, string tableName): // The CRM stats needs to be populated again m_countersCrmTable->del(CRM_COUNTERS_TABLE_KEY); - auto executor = new ExecutableTimer(m_timer.get(), this, "CRM_COUNTERS_POLL"); + // Note: ExecutableTimer will hold m_timer pointer and release the object later + auto executor = new ExecutableTimer(m_timer, this, "CRM_COUNTERS_POLL"); Orch::addExecutor(executor); m_timer->start(); } diff --git a/orchagent/crmorch.h b/orchagent/crmorch.h index fd850349d5..eac50da992 100644 --- a/orchagent/crmorch.h +++ b/orchagent/crmorch.h @@ -52,7 +52,7 @@ class CrmOrch : public Orch private: shared_ptr m_countersDb = nullptr; shared_ptr m_countersCrmTable = nullptr; - shared_ptr m_timer = nullptr; + SelectableTimer *m_timer = nullptr; struct CrmResourceCounter {