@@ -7,6 +7,9 @@ constexpr auto DEFAULT_TIMEOUT_MSEC = 1000;
7
7
8
8
bool pollSwssNotifcation = true ;
9
9
std::shared_ptr<boost::thread> mSwssThreadPtr ;
10
+
11
+ std::shared_ptr<swss::DBConnector> configDbPtr = std::make_shared<swss::DBConnector> (" CONFIG_DB" , 0 );
12
+ swss::SubscriberStateTable ipHelpersTable (configDbPtr.get(), "DHCP_RELAY");
10
13
swss::Select swssSelect;
11
14
12
15
/* *
@@ -19,14 +22,9 @@ swss::Select swssSelect;
19
22
void initialize_swss (std::vector<relay_config> *vlans)
20
23
{
21
24
try {
22
- std::shared_ptr<swss::DBConnector> configDbPtr = std::make_shared<swss::DBConnector> (" CONFIG_DB" , 0 );
23
- swss::SubscriberStateTable ipHelpersTable (configDbPtr.get (), " DHCP_RELAY" );
24
25
swssSelect.addSelectable (&ipHelpersTable);
25
- get_dhcp (vlans, &ipHelpersTable);
26
- struct swssNotification test;
27
- test.ipHelpersTable = &ipHelpersTable;
28
- test.vlans = vlans;
29
- mSwssThreadPtr = std::make_shared<boost::thread> (&handleSwssNotification, test);
26
+ get_dhcp (vlans);
27
+ mSwssThreadPtr = std::make_shared<boost::thread> (&handleSwssNotification, vlans);
30
28
}
31
29
catch (const std::bad_alloc &e) {
32
30
syslog (LOG_ERR, " Failed allocate memory. Exception details: %s" , e.what ());
@@ -54,15 +52,15 @@ void deinitialize_swss()
54
52
*
55
53
* @return none
56
54
*/
57
- void get_dhcp (std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHelpersTable ) {
55
+ void get_dhcp (std::vector<relay_config> *vlans) {
58
56
swss::Selectable *selectable;
59
57
int ret = swssSelect.select (&selectable, DEFAULT_TIMEOUT_MSEC);
60
58
if (ret == swss::Select::ERROR) {
61
59
syslog (LOG_WARNING, " Select: returned ERROR" );
62
60
} else if (ret == swss::Select::TIMEOUT) {
63
61
}
64
- if (selectable == static_cast <swss::Selectable *> (ipHelpersTable)) {
65
- handleRelayNotification (* ipHelpersTable, vlans);
62
+ if (selectable == static_cast <swss::Selectable *> (& ipHelpersTable)) {
63
+ handleRelayNotification (ipHelpersTable, vlans);
66
64
}
67
65
}
68
66
/* *
@@ -74,10 +72,10 @@ void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHe
74
72
*
75
73
* @return none
76
74
*/
77
- void handleSwssNotification (swssNotification test )
75
+ void handleSwssNotification (std::vector<relay_config> *vlans )
78
76
{
79
77
while (pollSwssNotifcation) {
80
- get_dhcp (test. vlans , test. ipHelpersTable );
78
+ get_dhcp (vlans);
81
79
}
82
80
}
83
81
0 commit comments