diff --git a/common/errorlistener.cpp b/common/errorlistener.cpp index b09eb24d2..15f3ec0ee 100644 --- a/common/errorlistener.cpp +++ b/common/errorlistener.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2019 Broadcom Inc. + * Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or + * its subsidiaries. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,8 +63,11 @@ namespace swss { json j = json::parse(data); // Filter the error notifications that the caller is not interested in. - if (!(((m_errorFlags & ERR_NOTIFY_POSITIVE_ACK) && (j["rc"] == "SWSS_RC_SUCCESS")) || - ((m_errorFlags & ERR_NOTIFY_FAIL) && (j["rc"] != "SWSS_RC_SUCCESS")))) + if ((j["rc"] == "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_POSITIVE_ACK)) + { + return -1; + } + if ((j["rc"] != "SWSS_RC_SUCCESS") && !(m_errorFlags & ERR_NOTIFY_FAIL)) { return -1; } diff --git a/common/errorlistener.h b/common/errorlistener.h index 2b0584ce9..6c700233d 100644 --- a/common/errorlistener.h +++ b/common/errorlistener.h @@ -1,5 +1,6 @@ /* - * Copyright 2019 Broadcom Inc. + * Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or + * its subsidiaries. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +21,7 @@ #include "notificationconsumer.h" #include "selectable.h" #include "table.h" -#include +#include "dbconnector.h" // Error notifications of interest to the error listener typedef enum @@ -39,10 +40,10 @@ namespace swss { static std::string getErrorChannelName(std::string& appTableName) { - std::string errorChnl = "ERROR_"; - errorChnl += appTableName + "_CHANNEL"; + std::string errorChannel = "ERROR_"; + errorChannel += appTableName + "_CHANNEL"; - return errorChnl; + return errorChannel; } int getFd() { return m_errorNotificationConsumer->getFd(); } diff --git a/common/errormap.cpp b/common/errormap.cpp index 16a19b5a0..ea1b99097 100644 --- a/common/errormap.cpp +++ b/common/errormap.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2019 Broadcom Inc. + * Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or + * its subsidiaries. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,16 +24,17 @@ namespace swss { ErrorMap::~ErrorMap() { } const ErrorMap::SwssStrToRCMap ErrorMap::m_swssStrToRC = { - { std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) }, - { std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) }, - { std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) }, - { std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) }, - { std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) }, - { std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) }, - { std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) }, - { std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) }, - { std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) }, - { std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) } + { std::make_pair("SWSS_RC_SUCCESS", SWSS_RC_SUCCESS) }, + { std::make_pair("SWSS_RC_INVALID_PARAM", SWSS_RC_INVALID_PARAM) }, + { std::make_pair("SWSS_RC_UNAVAIL", SWSS_RC_UNAVAIL) }, + { std::make_pair("SWSS_RC_NOT_FOUND", SWSS_RC_NOT_FOUND) }, + { std::make_pair("SWSS_RC_NO_MEMORY", SWSS_RC_NO_MEMORY) }, + { std::make_pair("SWSS_RC_EXISTS", SWSS_RC_EXISTS) }, + { std::make_pair("SWSS_RC_TABLE_FULL", SWSS_RC_TABLE_FULL) }, + { std::make_pair("SWSS_RC_IN_USE", SWSS_RC_IN_USE) }, + { std::make_pair("SWSS_RC_NOT_IMPLEMENTED", SWSS_RC_NOT_IMPLEMENTED) }, + { std::make_pair("SWSS_RC_FAILURE", SWSS_RC_FAILURE) }, + { std::make_pair("SWSS_RC_INVALID_OBJECT_ID", SWSS_RC_INVALID_OBJECT_ID)} }; const ErrorMap::SaiToSwssRCMap ErrorMap::m_saiToSwssRC = { @@ -45,15 +47,10 @@ namespace swss { { "SAI_STATUS_TABLE_FULL", "SWSS_RC_TABLE_FULL" }, { "SAI_STATUS_OBJECT_IN_USE", "SWSS_RC_IN_USE" }, { "SAI_STATUS_NOT_IMPLEMENTED", "SWSS_RC_NOT_IMPLEMENTED" }, - { "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" } + { "SAI_STATUS_FAILURE", "SWSS_RC_FAILURE" }, + { "SAI_STATUS_INVALID_OBJECT_ID", "SWSS_RC_INVALID_OBJECT_ID" } }; - ErrorMap &ErrorMap::getInstance() - { - static ErrorMap m_errorMap; - return m_errorMap; - } - std::string ErrorMap::getSwssRCStr(const std::string &saiRCStr) { std::string swssRCStr; diff --git a/common/errormap.h b/common/errormap.h index e64f4ce28..ae003873b 100644 --- a/common/errormap.h +++ b/common/errormap.h @@ -1,5 +1,6 @@ /* - * Copyright 2019 Broadcom Inc. + * Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or + * its subsidiaries. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +39,7 @@ namespace swss { SWSS_RC_IN_USE, SWSS_RC_NOT_IMPLEMENTED, SWSS_RC_FAILURE, + SWSS_RC_INVALID_OBJECT_ID, SWSS_RC_UNKNOWN }; @@ -47,7 +49,6 @@ namespace swss { static const SwssStrToRCMap m_swssStrToRC; static const SaiToSwssRCMap m_saiToSwssRC; - static ErrorMap &getInstance(); static std::string getSwssRCStr(const std::string &saiRCStr); static SwssRC getSwssRC(const std::string &swssRCStr); static std::string getSaiRCStr(SwssRC rc);