diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index 8b29f9bece..b90d85b6ef 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -3449,6 +3449,11 @@ int syncd_main(int argc, char **argv) #endif + FlexCounter::removeAllCounters(); + + // Stop notification thread before removing switch + stopNotificationsProcessingThread(); + status = sai_switch_api->remove_switch(gSwitchId); if (status != SAI_STATUS_SUCCESS) { @@ -3465,8 +3470,6 @@ int syncd_main(int argc, char **argv) SWSS_LOG_ERROR("failed to uninitialize api: %s", sai_serialize_status(status).c_str()); } - stopNotificationsProcessingThread(); - SWSS_LOG_NOTICE("uninitialize finished"); return EXIT_SUCCESS; diff --git a/syncd/syncd_flex_counter.cpp b/syncd/syncd_flex_counter.cpp index bdca497107..2419a7531d 100644 --- a/syncd/syncd_flex_counter.cpp +++ b/syncd/syncd_flex_counter.cpp @@ -331,6 +331,13 @@ void FlexCounter::removeCounterPlugin( } } +void FlexCounter::removeAllCounters() +{ + SWSS_LOG_ENTER(); + + g_flex_counters_map.clear(); +} + FlexCounter::~FlexCounter(void) { diff --git a/syncd/syncd_flex_counter.h b/syncd/syncd_flex_counter.h index 1771feb2ae..111fc82608 100644 --- a/syncd/syncd_flex_counter.h +++ b/syncd/syncd_flex_counter.h @@ -51,6 +51,7 @@ class FlexCounter _In_ std::string instanceId); static void removeCounterPlugin( _In_ std::string instanceId); + static void removeAllCounters(); FlexCounter( _In_ const FlexCounter&) = delete; diff --git a/syncd/syncd_notifications.cpp b/syncd/syncd_notifications.cpp index 7bc8ee1616..e4958e8196 100644 --- a/syncd/syncd_notifications.cpp +++ b/syncd/syncd_notifications.cpp @@ -559,8 +559,6 @@ void startNotificationsProcessingThread() runThread = true; ntf_process_thread = std::make_shared(ntf_process_function); - - ntf_process_thread->detach(); } void stopNotificationsProcessingThread()