File tree 2 files changed +22
-34
lines changed
2 files changed +22
-34
lines changed Original file line number Diff line number Diff line change @@ -65,14 +65,8 @@ int main(int argc, char **argv)
65
65
s.addSelectables (o->getSelectables ());
66
66
}
67
67
68
- while (true )
69
- {
70
- if (received_sigterm)
71
- {
72
- teammgr.cleanTeamProcesses (SIGTERM);
73
- received_sigterm = false ;
74
- }
75
-
68
+ while (!received_sigterm)
69
+ {
76
70
Selectable *sel;
77
71
int ret;
78
72
@@ -91,6 +85,8 @@ int main(int argc, char **argv)
91
85
auto *c = (Executor *)sel;
92
86
c->execute ();
93
87
}
88
+ teammgr.cleanTeamProcesses (SIGTERM);
89
+ SWSS_LOG_NOTICE (" Exiting" );
94
90
}
95
91
catch (const exception &e)
96
92
{
Original file line number Diff line number Diff line change @@ -32,36 +32,28 @@ int main(int argc, char **argv)
32
32
/* Register the signal handler for SIGTERM */
33
33
signal (SIGTERM, sig_handler);
34
34
35
- while ( 1 )
35
+ try
36
36
{
37
- try
38
- {
39
- NetLink netlink;
40
-
41
- netlink.registerGroup (RTNLGRP_LINK);
42
- cout << " Listens to teamd events..." << endl;
43
- netlink.dumpRequest (RTM_GETLINK);
44
-
45
- s.addSelectable (&netlink);
46
- while (true )
47
- {
48
- if (received_sigterm)
49
- {
50
- sync .cleanTeamSync ();
51
- received_sigterm = false ;
52
- }
37
+ NetLink netlink;
38
+ netlink.registerGroup (RTNLGRP_LINK);
39
+ cout << " Listens to teamd events..." << endl;
40
+ netlink.dumpRequest (RTM_GETLINK);
53
41
54
- Selectable *temps;
55
- s.select (&temps, 1000 ); // block for a second
56
- sync .periodic ();
57
- }
58
- }
59
- catch (const std::exception & e)
42
+ s.addSelectable (&netlink);
43
+ while (!received_sigterm)
60
44
{
61
- cout << " Exception \" " << e.what () << " \" had been thrown in deamon" << endl;
62
- return 0 ;
45
+ Selectable *temps;
46
+ s.select (&temps, 1000 ); // block for a second
47
+ sync .periodic ();
63
48
}
49
+ sync .cleanTeamSync ();
50
+ SWSS_LOG_NOTICE (" Received SIGTERM Exiting" );
51
+ }
52
+ catch (const std::exception & e)
53
+ {
54
+ cout << " Exception \" " << e.what () << " \" had been thrown in deamon" << endl;
55
+ return 0 ;
64
56
}
65
57
66
- return 1 ;
58
+ return 0 ;
67
59
}
You can’t perform that action at this time.
0 commit comments