Skip to content

Commit 4ef45ee

Browse files
committed
Merge pull request sonic-net#321 from yxieca/syncd
[syncd] stop notification thread before calling remove_switch() [notif] don't detach syncd notification thread So that we could join() it at shutdown time. Signed-off-by: Ying Xie <[email protected]> [flex counter] remove all flex counters before exiting syncd Remove the early quit Add log enter to removeAllCounters()
1 parent a314ac4 commit 4ef45ee

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

syncd/syncd.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -3449,6 +3449,11 @@ int syncd_main(int argc, char **argv)
34493449

34503450
#endif
34513451

3452+
FlexCounter::removeAllCounters();
3453+
3454+
// Stop notification thread before removing switch
3455+
stopNotificationsProcessingThread();
3456+
34523457
status = sai_switch_api->remove_switch(gSwitchId);
34533458
if (status != SAI_STATUS_SUCCESS)
34543459
{
@@ -3465,8 +3470,6 @@ int syncd_main(int argc, char **argv)
34653470
SWSS_LOG_ERROR("failed to uninitialize api: %s", sai_serialize_status(status).c_str());
34663471
}
34673472

3468-
stopNotificationsProcessingThread();
3469-
34703473
SWSS_LOG_NOTICE("uninitialize finished");
34713474

34723475
return EXIT_SUCCESS;

syncd/syncd_flex_counter.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ void FlexCounter::removeCounterPlugin(
331331
}
332332
}
333333

334+
void FlexCounter::removeAllCounters()
335+
{
336+
SWSS_LOG_ENTER();
337+
338+
g_flex_counters_map.clear();
339+
}
340+
334341

335342
FlexCounter::~FlexCounter(void)
336343
{

syncd/syncd_flex_counter.h

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class FlexCounter
5151
_In_ std::string instanceId);
5252
static void removeCounterPlugin(
5353
_In_ std::string instanceId);
54+
static void removeAllCounters();
5455

5556
FlexCounter(
5657
_In_ const FlexCounter&) = delete;

syncd/syncd_notifications.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,6 @@ void startNotificationsProcessingThread()
559559
runThread = true;
560560

561561
ntf_process_thread = std::make_shared<std::thread>(ntf_process_function);
562-
563-
ntf_process_thread->detach();
564562
}
565563

566564
void stopNotificationsProcessingThread()

0 commit comments

Comments
 (0)