Skip to content

Commit

Permalink
Merge pull request sonic-net#321 from yxieca/syncd
Browse files Browse the repository at this point in the history
[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 <ying.xie@microsoft.com>

[flex counter] remove all flex counters before exiting syncd

Remove the early quit

Add log enter to removeAllCounters()
  • Loading branch information
yxieca authored and lguohan committed May 24, 2018
1 parent c860472 commit be0d9c3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,12 @@ int syncd_main(int argc, char **argv)
SWSS_LOG_NOTICE("Removing the switch gSwitchId=0x%lx", gSwitchId);
sai_switch_api_t *sai_switch_api = NULL;
sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api);

FlexCounter::removeAllCounters();

// Stop notification thread before removing switch
stopNotificationsProcessingThread();

status = sai_switch_api->remove_switch(gSwitchId);
if (status != SAI_STATUS_SUCCESS)
{
Expand All @@ -3413,8 +3419,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;
Expand Down
7 changes: 7 additions & 0 deletions syncd/syncd_flex_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ void FlexCounter::removeCounterPlugin(
}
}

void FlexCounter::removeAllCounters()
{
SWSS_LOG_ENTER();

g_flex_counters_map.clear();
}


FlexCounter::~FlexCounter(void)
{
Expand Down
1 change: 1 addition & 0 deletions syncd/syncd_flex_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions syncd/syncd_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ void startNotificationsProcessingThread()
runThread = true;

ntf_process_thread = std::make_shared<std::thread>(ntf_process_function);

ntf_process_thread->detach();
}

void stopNotificationsProcessingThread()
Expand Down

0 comments on commit be0d9c3

Please sign in to comment.