File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
3
#define MUTEX () std::lock_guard<std::recursive_mutex> _lock (m_apimutex)
4
+ #define MUTEX_UNLOCK () m_apimutex.unlock()
Original file line number Diff line number Diff line change @@ -196,6 +196,25 @@ sai_status_t Sai::set(
196
196
197
197
if (RedisRemoteSaiInterface::isRedisAttribute (objectType, attr))
198
198
{
199
+ if (attr->id == SAI_REDIS_SWITCH_ATTR_REDIS_COMMUNICATION_MODE)
200
+ {
201
+ // Since communication mode destroys current channel and creates
202
+ // new one, it may happen, that during this SET api execution when
203
+ // api mutex is acquired, channel destructor will be blocking on
204
+ // thread->join() and channel thread will start processing
205
+ // incoming notification. That notification will be synchronized
206
+ // with api mutex and will cause deadlock, so to mitigate this
207
+ // scenario we will unlock api mutex here.
208
+ //
209
+ // This is not the perfect, but assuming that communication mode is
210
+ // changed in single thread and before switch create then we should
211
+ // not hit race condition.
212
+
213
+ SWSS_LOG_NOTICE (" unlocking api mutex for communication mode" );
214
+
215
+ MUTEX_UNLOCK ();
216
+ }
217
+
199
218
// skip metadata if attribute is redis extension attribute
200
219
201
220
// TODO this is setting on all contexts, but maybe we want one specific?
You can’t perform that action at this time.
0 commit comments