Skip to content

Commit 0b1b67e

Browse files
lobisccaffy
authored andcommitted
MGM: Traffic Shaping - Improve locking
Fix deadlock in Start()/Stop(): both are called from Enable()/Disable() via FsView::ApplyGlobalConfig() while IConfigEngine::ApplyConfig() holds the ViewMutex write lock. SyncTrafficShapingEnabledWithFst() acquires a read lock on the same thread causing a deadlock. Removed it from Start()/Stop(); the call in TrafficShapingEngine::ApplyConfig() (after the lock is released) provides the immediate FST notification on startup. Other fixes: - Minimize ViewMutex hold time in UpdateLimits() and SyncTrafficShapingEnabledWithFst(): snapshot online node names under a brief read lock, then re-acquire per-node for SetConfigMember - Release mMutex before SetGlobalConfig/AutoSave in all Set/RemoveXxxPolicy methods to avoid holding it during slow config-engine I/O - Snapshot mAppPolicies under a shared lock in UpdateTrafficShapingController() to fix a data race with concurrent Set/RemoveAppPolicy calls - Move mMutex acquisition before JSON parsing in LoadPoliciesFromString() - Replace sleep_until with assistant.wait_for() in all three background threads so termination requests wake them immediately - Join mFstTrafficShapingConfigUpdateThread in Stop() — it was started but never joined, leaving it running after stop - Add Clear() call to TrafficShapingManager destructor - Fix UB cast in CalculateDelayUs: clamp to zero before casting to uint64_t - Drop oldest reports instead of clearing the queue on overflow
1 parent 7f50e14 commit 0b1b67e

File tree

1 file changed

+214
-137
lines changed

1 file changed

+214
-137
lines changed

0 commit comments

Comments
 (0)