-
Notifications
You must be signed in to change notification settings - Fork 693
Teamd :: fix for cleaning up the teamd processes correctly on teamd docker stop #1159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
581e873
d4b473b
b2c023e
aa55cbb
d991280
7264c8d
c61135f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| #include "netlink.h" | ||
| #include "select.h" | ||
| #include "warm_restart.h" | ||
| #include <signal.h> | ||
|
|
||
| using namespace std; | ||
| using namespace swss; | ||
|
|
@@ -17,13 +18,24 @@ bool gLogRotate = false; | |
| ofstream gRecordOfs; | ||
| string gRecordFile; | ||
|
|
||
| bool received_sigterm = false; | ||
|
|
||
| void sig_handler(int signo) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
check signo == SIGTERM first?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Signal handler is only registered only for SIGTERM now. The handler will be called only on SIGTERM signal. |
||
| { | ||
| received_sigterm = true; | ||
| return; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| Logger::linkToDbNative("teammgrd"); | ||
| SWSS_LOG_ENTER(); | ||
|
|
||
| SWSS_LOG_NOTICE("--- Starting teammrgd ---"); | ||
|
|
||
| /* Register the signal handler for SIGTERM */ | ||
| signal(SIGTERM, sig_handler); | ||
|
|
||
| try | ||
| { | ||
| DBConnector conf_db("CONFIG_DB", 0); | ||
|
|
@@ -55,6 +67,12 @@ int main(int argc, char **argv) | |
|
|
||
| while (true) | ||
pavel-shirshov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| if(received_sigterm) | ||
| { | ||
| teammgr.cleanTeamProcesses(SIGTERM); | ||
| received_sigterm = false; | ||
pavel-shirshov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| Selectable *sel; | ||
| int ret; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #include <iostream> | ||
| #include <team.h> | ||
| #include <signal.h> | ||
| #include "logger.h" | ||
| #include "select.h" | ||
| #include "netdispatcher.h" | ||
|
|
@@ -9,6 +10,14 @@ | |
| using namespace std; | ||
| using namespace swss; | ||
|
|
||
| bool received_sigterm = false; | ||
|
|
||
| void sig_handler(int signo) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
the same
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Signal handler is only registered only for SIGTERM now. The handler will be called only on SIGTERM signal. |
||
| { | ||
| received_sigterm = true; | ||
| return; | ||
| } | ||
|
|
||
| int main(int argc, char **argv) | ||
| { | ||
| swss::Logger::linkToDbNative(TEAMSYNCD_APP_NAME); | ||
|
|
@@ -20,6 +29,9 @@ int main(int argc, char **argv) | |
| NetDispatcher::getInstance().registerMessageHandler(RTM_NEWLINK, &sync); | ||
| NetDispatcher::getInstance().registerMessageHandler(RTM_DELLINK, &sync); | ||
|
|
||
| /* Register the signal handler for SIGTERM */ | ||
| signal(SIGTERM, sig_handler); | ||
|
|
||
| while (1) | ||
| { | ||
| try | ||
|
|
@@ -33,6 +45,12 @@ int main(int argc, char **argv) | |
| s.addSelectable(&netlink); | ||
| while (true) | ||
| { | ||
| if(received_sigterm) | ||
| { | ||
| sync.cleanTeamSync(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation. |
||
| received_sigterm = false; | ||
| } | ||
pavel-shirshov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Selectable *temps; | ||
| s.select(&temps, 1000); // block for a second | ||
| sync.periodic(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.