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