Skip to content

Commit 8e4cd87

Browse files
committed
Clean up
1 parent 78c9d5f commit 8e4cd87

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

src/configInterface.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ 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");
1013
swss::Select swssSelect;
1114

1215
/**
@@ -19,14 +22,9 @@ swss::Select swssSelect;
1922
void initialize_swss(std::vector<relay_config> *vlans)
2023
{
2124
try {
22-
std::shared_ptr<swss::DBConnector> configDbPtr = std::make_shared<swss::DBConnector> ("CONFIG_DB", 0);
23-
swss::SubscriberStateTable ipHelpersTable(configDbPtr.get(), "DHCP_RELAY");
2425
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);
3028
}
3129
catch (const std::bad_alloc &e) {
3230
syslog(LOG_ERR, "Failed allocate memory. Exception details: %s", e.what());
@@ -54,15 +52,15 @@ void deinitialize_swss()
5452
*
5553
* @return none
5654
*/
57-
void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHelpersTable) {
55+
void get_dhcp(std::vector<relay_config> *vlans) {
5856
swss::Selectable *selectable;
5957
int ret = swssSelect.select(&selectable, DEFAULT_TIMEOUT_MSEC);
6058
if (ret == swss::Select::ERROR) {
6159
syslog(LOG_WARNING, "Select: returned ERROR");
6260
} else if (ret == swss::Select::TIMEOUT) {
6361
}
64-
if (selectable == static_cast<swss::Selectable *> (ipHelpersTable)) {
65-
handleRelayNotification(*ipHelpersTable, vlans);
62+
if (selectable == static_cast<swss::Selectable *> (&ipHelpersTable)) {
63+
handleRelayNotification(ipHelpersTable, vlans);
6664
}
6765
}
6866
/**
@@ -74,10 +72,10 @@ void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHe
7472
*
7573
* @return none
7674
*/
77-
void handleSwssNotification(swssNotification test)
75+
void handleSwssNotification(std::vector<relay_config> *vlans)
7876
{
7977
while (pollSwssNotifcation) {
80-
get_dhcp(test.vlans, test.ipHelpersTable);
78+
get_dhcp(vlans);
8179
}
8280
}
8381

src/configInterface.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
#pragma once
2-
31
#include <boost/thread.hpp>
42
#include "subscriberstatetable.h"
53
#include "select.h"
64
#include "relay.h"
75

8-
struct swssNotification {
9-
std::vector<relay_config> *vlans;
10-
swss::SubscriberStateTable *ipHelpersTable;
11-
};
126
/**
137
* @code void initialize_swss()
148
*
@@ -34,7 +28,7 @@ void deinitialize_swss();
3428
*
3529
* @return none
3630
*/
37-
void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHelpersTable);
31+
void get_dhcp(std::vector<relay_config> *vlans);
3832

3933
/**
4034
* @code void handleSwssNotification(std::vector<relay_config> *vlans)
@@ -45,7 +39,7 @@ void get_dhcp(std::vector<relay_config> *vlans, swss::SubscriberStateTable *ipHe
4539
*
4640
* @return none
4741
*/
48-
void handleSwssNotification(swssNotification test);
42+
void handleSwssNotification(std::vector<relay_config> *vlans);
4943

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

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ int main(int argc, char *argv[]) {
3333
return 1;
3434
}
3535
return 0;
36-
}
36+
}

0 commit comments

Comments
 (0)