Skip to content

Commit 0af9187

Browse files
committed
Fix double lock from the same thread
1 parent a072b31 commit 0af9187

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

syncd/syncd.cpp

+12-8
Original file line numberDiff line numberDiff line change
@@ -1207,12 +1207,14 @@ sai_status_t handle_generic(
12071207
* To support multiple switches vid/rid map must be per switch.
12081208
*/
12091209

1210-
std::lock_guard<std::mutex> lock(g_db_mutex);
1210+
{
1211+
std::lock_guard<std::mutex> lock(g_db_mutex);
12111212

1212-
g_redisClient->hset(VIDTORID, str_vid, str_rid);
1213-
g_redisClient->hset(RIDTOVID, str_rid, str_vid);
1213+
g_redisClient->hset(VIDTORID, str_vid, str_rid);
1214+
g_redisClient->hset(RIDTOVID, str_rid, str_vid);
12141215

1215-
save_rid_and_vid_to_local(real_object_id, object_id);
1216+
save_rid_and_vid_to_local(real_object_id, object_id);
1217+
}
12161218

12171219
SWSS_LOG_INFO("saved VID %s to RID %s", str_vid.c_str(), str_rid.c_str());
12181220

@@ -1243,12 +1245,14 @@ sai_status_t handle_generic(
12431245
* TODO: This must be ATOMIC.
12441246
*/
12451247

1246-
std::lock_guard<std::mutex> lock(g_db_mutex);
1248+
{
1249+
std::lock_guard<std::mutex> lock(g_db_mutex);
12471250

1248-
g_redisClient->hdel(VIDTORID, str_vid);
1249-
g_redisClient->hdel(RIDTOVID, str_rid);
1251+
g_redisClient->hdel(VIDTORID, str_vid);
1252+
g_redisClient->hdel(RIDTOVID, str_rid);
12501253

1251-
remove_rid_and_vid_from_local(rid, object_id);
1254+
remove_rid_and_vid_from_local(rid, object_id);
1255+
}
12521256

12531257
if (object_type == SAI_OBJECT_TYPE_SWITCH)
12541258
{

0 commit comments

Comments
 (0)