Skip to content

Commit 5fc89b5

Browse files
kcudniklguohan
authored andcommitted
Revert Process flex counters requests in separate thread (sonic-net#483) (sonic-net#505)
1 parent 1d03c55 commit 5fc89b5

File tree

1 file changed

+6
-88
lines changed

1 file changed

+6
-88
lines changed

syncd/syncd.cpp

+6-88
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ std::shared_ptr<swss::RedisClient> g_redisClient;
3939
std::shared_ptr<swss::ProducerTable> getResponse;
4040
std::shared_ptr<swss::NotificationProducer> notifications;
4141

42-
std::shared_ptr<std::thread> g_processFlexCounterEventThread;
43-
volatile bool g_processFlexCounterEventThreadRun = true;
44-
4542
/*
4643
* TODO: Those are hard coded values for mlnx integration for v1.0.1 they need
4744
* to be updated.
@@ -3002,62 +2999,6 @@ void processFlexCounterGroupEvent(
30022999
}
30033000
}
30043001

3005-
std::queue<swss::KeyOpFieldsValuesTuple> g_flexCounterEventQueue;
3006-
3007-
bool tryPopFlexCounterEvent(
3008-
_Out_ swss::KeyOpFieldsValuesTuple& kco)
3009-
{
3010-
SWSS_LOG_ENTER();
3011-
3012-
std::lock_guard<std::mutex> lock(g_mutex);
3013-
3014-
if (g_flexCounterEventQueue.empty())
3015-
{
3016-
return false;
3017-
}
3018-
3019-
kco = g_flexCounterEventQueue.front();
3020-
3021-
g_flexCounterEventQueue.pop();
3022-
3023-
return true;
3024-
}
3025-
3026-
void pushFlexCounterEvent(
3027-
_In_ const swss::KeyOpFieldsValuesTuple& kco)
3028-
{
3029-
SWSS_LOG_ENTER();
3030-
3031-
std::lock_guard<std::mutex> lock(g_mutex);
3032-
3033-
g_flexCounterEventQueue.push(kco);
3034-
}
3035-
3036-
bool processFlexCounterEvent(
3037-
_In_ const swss::KeyOpFieldsValuesTuple kco);
3038-
3039-
void processFlexCounterEventThread()
3040-
{
3041-
SWSS_LOG_ENTER();
3042-
3043-
while (g_processFlexCounterEventThreadRun)
3044-
{
3045-
swss::KeyOpFieldsValuesTuple kco;
3046-
3047-
if (tryPopFlexCounterEvent(kco))
3048-
{
3049-
if (!processFlexCounterEvent(kco))
3050-
{
3051-
// event was not successfully processed, put it again to the queue
3052-
3053-
pushFlexCounterEvent(kco);
3054-
}
3055-
}
3056-
3057-
sleep(1);
3058-
}
3059-
}
3060-
30613002
void processFlexCounterEvent(
30623003
_In_ swss::ConsumerTable &consumer)
30633004
{
@@ -3070,30 +3011,15 @@ void processFlexCounterEvent(
30703011
consumer.pop(kco);
30713012
}
30723013

3073-
// because flex counter event can arrive independently (on RIF interface)
3074-
// it may happen that it will be picked up from the select api before
3075-
// actual interface will be created, and subscription for counters will
3076-
// fail, so let's process each request in the thread and use queue for
3077-
// arriving events, and failed events will be put back to the queue until
3078-
// they will be processed
3079-
3080-
pushFlexCounterEvent(kco);
3081-
}
3082-
3083-
bool processFlexCounterEvent(
3084-
_In_ const swss::KeyOpFieldsValuesTuple kco)
3085-
{
3086-
SWSS_LOG_ENTER();
3087-
30883014
const auto &key = kfvKey(kco);
3089-
const std::string &op = kfvOp(kco);
3015+
std::string op = kfvOp(kco);
30903016

30913017
std::size_t delimiter = key.find_first_of(":");
30923018
if (delimiter == std::string::npos)
30933019
{
30943020
SWSS_LOG_ERROR("Failed to parse the key %s", key.c_str());
30953021

3096-
return true; // if key is invalid there is no need to process this event again
3022+
return; // if key is invalid there is no need to process this event again
30973023
}
30983024

30993025
const auto groupName = key.substr(0, delimiter);
@@ -3105,10 +3031,11 @@ bool processFlexCounterEvent(
31053031
{
31063032
std::lock_guard<std::mutex> lock(g_mutex);
31073033
if (!try_translate_vid_to_rid(vid, rid))
3108-
{
3034+
{
31093035
SWSS_LOG_WARN("port VID %s, was not found (probably port was removed/splitted) and will remove from counters now",
31103036
sai_serialize_object_id(vid).c_str());
3111-
return false;
3037+
3038+
op = DEL_COMMAND;
31123039
}
31133040
}
31143041

@@ -3255,7 +3182,7 @@ bool processFlexCounterEvent(
32553182
FlexCounter::setBufferPoolCounterList(vid, rid, groupName, bufferPoolCounterIds, statsMode);
32563183
}
32573184

3258-
return true;
3185+
return;
32593186
}
32603187

32613188
void printUsage()
@@ -3979,11 +3906,6 @@ int syncd_main(int argc, char **argv)
39793906

39803907
twd.setCallback(timerWatchdogCallback);
39813908

3982-
g_processFlexCounterEventThreadRun = true;
3983-
3984-
g_processFlexCounterEventThread = std::make_shared<std::thread>(processFlexCounterEventThread);
3985-
3986-
39873909
while(runMainLoop)
39883910
{
39893911
try
@@ -4167,10 +4089,6 @@ int syncd_main(int argc, char **argv)
41674089

41684090
#endif
41694091

4170-
g_processFlexCounterEventThreadRun = false;
4171-
4172-
g_processFlexCounterEventThread->join();
4173-
41744092
FlexCounter::removeAllCounters();
41754093

41764094
{

0 commit comments

Comments
 (0)