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 committed May 24, 2018
1 parent a314ac4 commit 4ef45ee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
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 4ef45ee

Please sign in to comment.