diff --git a/syncd/syncd.cpp b/syncd/syncd.cpp index b921a318552a..ca3137389be0 100644 --- a/syncd/syncd.cpp +++ b/syncd/syncd.cpp @@ -39,9 +39,6 @@ std::shared_ptr g_redisClient; std::shared_ptr getResponse; std::shared_ptr notifications; -std::shared_ptr g_processFlexCounterEventThread; -volatile bool g_processFlexCounterEventThreadRun = true; - /* * TODO: Those are hard coded values for mlnx integration for v1.0.1 they need * to be updated. @@ -3002,62 +2999,6 @@ void processFlexCounterGroupEvent( } } -std::queue g_flexCounterEventQueue; - -bool tryPopFlexCounterEvent( - _Out_ swss::KeyOpFieldsValuesTuple& kco) -{ - SWSS_LOG_ENTER(); - - std::lock_guard lock(g_mutex); - - if (g_flexCounterEventQueue.empty()) - { - return false; - } - - kco = g_flexCounterEventQueue.front(); - - g_flexCounterEventQueue.pop(); - - return true; -} - -void pushFlexCounterEvent( - _In_ const swss::KeyOpFieldsValuesTuple& kco) -{ - SWSS_LOG_ENTER(); - - std::lock_guard lock(g_mutex); - - g_flexCounterEventQueue.push(kco); -} - -bool processFlexCounterEvent( - _In_ const swss::KeyOpFieldsValuesTuple kco); - -void processFlexCounterEventThread() -{ - SWSS_LOG_ENTER(); - - while (g_processFlexCounterEventThreadRun) - { - swss::KeyOpFieldsValuesTuple kco; - - if (tryPopFlexCounterEvent(kco)) - { - if (!processFlexCounterEvent(kco)) - { - // event was not successfully processed, put it again to the queue - - pushFlexCounterEvent(kco); - } - } - - sleep(1); - } -} - void processFlexCounterEvent( _In_ swss::ConsumerTable &consumer) { @@ -3070,30 +3011,15 @@ void processFlexCounterEvent( consumer.pop(kco); } - // because flex counter event can arrive independently (on RIF interface) - // it may happen that it will be picked up from the select api before - // actual interface will be created, and subscription for counters will - // fail, so let's process each request in the thread and use queue for - // arriving events, and failed events will be put back to the queue until - // they will be processed - - pushFlexCounterEvent(kco); -} - -bool processFlexCounterEvent( - _In_ const swss::KeyOpFieldsValuesTuple kco) -{ - SWSS_LOG_ENTER(); - const auto &key = kfvKey(kco); - const std::string &op = kfvOp(kco); + std::string op = kfvOp(kco); std::size_t delimiter = key.find_first_of(":"); if (delimiter == std::string::npos) { SWSS_LOG_ERROR("Failed to parse the key %s", key.c_str()); - return true; // if key is invalid there is no need to process this event again + return; // if key is invalid there is no need to process this event again } const auto groupName = key.substr(0, delimiter); @@ -3105,10 +3031,11 @@ bool processFlexCounterEvent( { std::lock_guard lock(g_mutex); if (!try_translate_vid_to_rid(vid, rid)) - { + { SWSS_LOG_WARN("port VID %s, was not found (probably port was removed/splitted) and will remove from counters now", sai_serialize_object_id(vid).c_str()); - return false; + + op = DEL_COMMAND; } } @@ -3255,7 +3182,7 @@ bool processFlexCounterEvent( FlexCounter::setBufferPoolCounterList(vid, rid, groupName, bufferPoolCounterIds, statsMode); } - return true; + return; } void printUsage() @@ -3979,11 +3906,6 @@ int syncd_main(int argc, char **argv) twd.setCallback(timerWatchdogCallback); - g_processFlexCounterEventThreadRun = true; - - g_processFlexCounterEventThread = std::make_shared(processFlexCounterEventThread); - - while(runMainLoop) { try @@ -4167,10 +4089,6 @@ int syncd_main(int argc, char **argv) #endif - g_processFlexCounterEventThreadRun = false; - - g_processFlexCounterEventThread->join(); - FlexCounter::removeAllCounters(); {