Skip to content

Commit

Permalink
acquire lock before accessing shared redis context (sonic-net#489)
Browse files Browse the repository at this point in the history
* fixed issue of permenent block on redisBufferRead() due to unprotected access from different threads

syncd main thread was doing g_redisClient->hget without acquiring g_mutex, thereby causing either syncd main thread or notification thread to block indefinitely on redisBufferRead().

* Delete .DS_Store

.

* resolved merge conflict

* Revert "resolved merge conflict"

This reverts commit f0094914cb93249482ee79fc5d4db402aecf79d6.

* Revert "Merge remote-tracking branch 'upstream/master'"

This reverts commit 550aca906c4f0ccca0d03a95c96152e9a37abae1, reversing
changes made to 676c0b58c4452478161d14a04140ed663127e91d.

* Revert "Revert "Merge remote-tracking branch 'upstream/master'""

This reverts commit 03fc996e8c530505a3ad22b23e75ef2c77ebc668.

* Revert "Revert "resolved merge conflict""

This reverts commit e840a6b0f4d2df1679d654796f4e303f73d98abe.

* Update syncd.cpp

* Update syncd.cpp

* Update syncd.cpp

* Update syncd.cpp
  • Loading branch information
anilkpandey authored and kcudnik committed Jul 24, 2019
1 parent 736eb05 commit 3a8fc6f
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit 3a8fc6f

Please sign in to comment.