Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acquire lock before accessing shared redis context #489

Merged
merged 12 commits into from
Jul 24, 2019
13 changes: 7 additions & 6 deletions syncd/syncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3101,13 +3101,14 @@ bool processFlexCounterEvent(
sai_object_id_t vid = SAI_NULL_OBJECT_ID;
sai_deserialize_object_id(vidStr, vid);
sai_object_id_t rid;

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;
std::lock_guard<std::mutex> 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;
}
}

sai_object_type_t objectType = redis_sai_object_type_query(vid); // VID and RID will have the same object type
Expand Down