Skip to content

Commit 713a305

Browse files
committed
Fix redis
1 parent 0330abc commit 713a305

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/configInterface.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ constexpr auto DEFAULT_TIMEOUT_MSEC = 1000;
77

88
bool pollSwssNotifcation = true;
99
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");
1310
swss::Select swssSelect;
1411

1512
/**
@@ -22,9 +19,14 @@ swss::Select swssSelect;
2219
void initialize_swss(std::vector<relay_config> *vlans)
2320
{
2421
try {
22+
std::shared_ptr<swss::DBConnector> configDbPtr = std::make_shared<swss::DBConnector> ("CONFIG_DB", 0);
23+
swss::SubscriberStateTable ipHelpersTable(configDbPtr.get(), "DHCP_RELAY");
2524
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);
2830
}
2931
catch (const std::bad_alloc &e) {
3032
syslog(LOG_ERR, "Failed allocate memory. Exception details: %s", e.what());
@@ -52,15 +54,15 @@ void deinitialize_swss()
5254
*
5355
* @return none
5456
*/
55-
void get_dhcp(std::vector<relay_config> *vlans) {
57+
void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHelpersTable) {
5658
swss::Selectable *selectable;
5759
int ret = swssSelect.select(&selectable, DEFAULT_TIMEOUT_MSEC);
5860
if (ret == swss::Select::ERROR) {
5961
syslog(LOG_WARNING, "Select: returned ERROR");
6062
} else if (ret == swss::Select::TIMEOUT) {
6163
}
62-
if (selectable == static_cast<swss::Selectable *> (&ipHelpersTable)) {
63-
handleRelayNotification(ipHelpersTable, vlans);
64+
if (selectable == static_cast<swss::Selectable *> (ipHelpersTable)) {
65+
handleRelayNotification(*ipHelpersTable, vlans);
6466
}
6567
}
6668
/**
@@ -72,10 +74,10 @@ void get_dhcp(std::vector<relay_config> *vlans) {
7274
*
7375
* @return none
7476
*/
75-
void handleSwssNotification(std::vector<relay_config> *vlans)
77+
void handleSwssNotification(swssNotification test)
7678
{
7779
while (pollSwssNotifcation) {
78-
get_dhcp(vlans);
80+
get_dhcp(test.vlans, test.ipHelpersTable);
7981
}
8082
}
8183

src/configInterface.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
#pragma once
2+
13
#include <boost/thread.hpp>
24
#include "subscriberstatetable.h"
35
#include "select.h"
46
#include "relay.h"
57

8+
struct swssNotification {
9+
std::vector<relay_config> *vlans;
10+
swss::SubscriberStateTable *ipHelpersTable;
11+
};
612
/**
713
* @code void initialize_swss()
814
*
@@ -28,18 +34,18 @@ void deinitialize_swss();
2834
*
2935
* @return none
3036
*/
31-
void get_dhcp(std::vector<relay_config> *vlans);
37+
void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHelpersTable);
3238

3339
/**
34-
* @code void handleSwssNotification(std::vector<relay_config> *vlans)
40+
* @code void swssNotification test
3541
*
3642
* @brief main thread for handling SWSS notification
3743
*
38-
* @param vlans list of vlans/argument config that contains strings of server and option
44+
* @param test swssNotification that includes list of vlans/argument config that contains strings of server and option
3945
*
4046
* @return none
4147
*/
42-
void handleSwssNotification(std::vector<relay_config> *vlans);
48+
void handleSwssNotification(swssNotification test);
4349

4450
/**
4551
* @code void handleRelayNotification(swss::SubscriberStateTable &ipHelpersTable, std::vector<relay_config> *vlans)

0 commit comments

Comments
 (0)