diff --git a/common/consumertable.cpp b/common/consumertable.cpp index c3ed28ab7..5840622a1 100644 --- a/common/consumertable.cpp +++ b/common/consumertable.cpp @@ -38,6 +38,7 @@ ConsumerTable::ConsumerTable(DBConnector *db, string tableName) : catch (...) { delete m_subscribe; + m_subscribe = NULL; } } diff --git a/common/scheme.h b/common/scheme.h index 30fb74de9..68bc8df73 100644 --- a/common/scheme.h +++ b/common/scheme.h @@ -1,17 +1,28 @@ #ifndef __SCHEME__ #define __SCHEME__ + +#define _in_ +#define _out_ +#define _inout_ + namespace swss { #define APPL_DB 0 #define ASIC_DB 1 -#define APP_PORT_TABLE_NAME "PORT_TABLE" -#define APP_VLAN_TABLE_NAME "VLAN_TABLE" -#define APP_LAG_TABLE_NAME "LAG_TABLE" -#define APP_INTF_TABLE_NAME "INTF_TABLE" -#define APP_NEIGH_TABLE_NAME "NEIGH_TABLE" -#define APP_ROUTE_TABLE_NAME "ROUTE_TABLE" +#define APP_PORT_TABLE_NAME "PORT_TABLE" +#define APP_VLAN_TABLE_NAME "VLAN_TABLE" +#define APP_LAG_TABLE_NAME "LAG_TABLE" +#define APP_INTF_TABLE_NAME "INTF_TABLE" +#define APP_NEIGH_TABLE_NAME "NEIGH_TABLE" +#define APP_ROUTE_TABLE_NAME "ROUTE_TABLE" +#define APP_TC_TO_QUEUE_MAP_TABLE_NAME "TC_TO_QUEUE_MAP_TABLE" +#define APP_SCHEDULER_TABLE_NAME "SCHEDULER_TABLE" +#define APP_DSCP_TO_TC_MAP_TABLE_NAME "DSCP_TO_TC_MAP_TABLE" +#define APP_QUEUE_TABLE_NAME "QUEUE_TABLE" +#define APP_PORT_QOS_MAP_TABLE_NAME "PORT_QOS_MAP_TABLE" +#define APP_WRED_PROFILE_TABLE_NAME "WRED_PROFILE_TABLE" #define IPV4_NAME "IPv4" #define IPV6_NAME "IPv6" diff --git a/common/select.cpp b/common/select.cpp index 0c4312308..580c0a306 100644 --- a/common/select.cpp +++ b/common/select.cpp @@ -1,4 +1,6 @@ +#include #include "common/selectable.h" +#include "common/logger.h" #include "common/select.h" #include #include @@ -8,9 +10,20 @@ using namespace std; namespace swss { -void Select::addSelectable(Selectable *c) +void Select::addSelectable(_in_ Selectable *selectable) { - m_objects.push_back(c); + if(std::find(m_objects.begin(), m_objects.end(), selectable) != m_objects.end()) { + SWSS_LOG_WARN("Selectable:%p already been added to the list, ignoring\n."); + return; + } + m_objects.push_back(selectable); +} + +void Select::addSelectables(_in_ std::vector &selectables) +{ + for(auto it : selectables) { + addSelectable(it); + } } void Select::addFd(int fd) @@ -18,7 +31,7 @@ void Select::addFd(int fd) m_fds.push_back(fd); } -int Select::select(Selectable **c, int *fd, unsigned int timeout) +int Select::select(_out_ Selectable **c, _out_ int *fd, _in_ unsigned int timeout) { struct timeval t = {0, (suseconds_t)(timeout)*1000}; struct timeval *pTimeout = NULL; diff --git a/common/select.h b/common/select.h index 76617cbec..0c8158055 100644 --- a/common/select.h +++ b/common/select.h @@ -13,7 +13,8 @@ class Select { public: /* Add object for select */ - void addSelectable(Selectable *c); + void addSelectables(_in_ std::vector &selectables); + void addSelectable(_in_ Selectable *selectable); /* Add file-descriptor for select */ void addFd(int fd); @@ -28,8 +29,7 @@ class Select ERROR = 2, TIMEOUT = 3 }; - int select(Selectable **c, int *fd, - unsigned int timeout = std::numeric_limits::max()); + int select(_out_ Selectable **c, _out_ int *fd, _in_ unsigned int timeout = std::numeric_limits::max()); private: /* Create a new redisContext, SELECT DB and SUBSRIBE */ diff --git a/common/table.cpp b/common/table.cpp index 1fccae179..4d32b7cc8 100644 --- a/common/table.cpp +++ b/common/table.cpp @@ -15,6 +15,11 @@ Table::Table(DBConnector *db, string tableName) : { } +std::string Table::getTableName()const +{ + return m_tableName; +} + string Table::getKeyName(string key) { return m_tableName + ':' + key; diff --git a/common/table.h b/common/table.h index d079341ff..2816e9663 100644 --- a/common/table.h +++ b/common/table.h @@ -38,11 +38,11 @@ class Table { void delField(std::string key, std::string field); virtual ~Table(); + std::string getTableName()const; protected: /* Return the actual key name as a comibation of tableName:key */ std::string getKeyName(std::string key); - std::string getKeyQueueTableName(); std::string getValueQueueTableName(); std::string getOpQueueTableName();