Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix potential deadlock inside unregisterCallback()
Summary: Special thanks to andriigrynenko for pointing out the potential dead lock problem when implementing a dynamic counter inside another dynamic counter. Dead lock example explained: a,b are both dynamic counters (callback counter) where b's lambda calls getCounter(a) 1. thread 1 called getCounter(b) 2. thread 1 locked the map, got pointer to a counter, unlocked the map 3. thread 1 grabbed the callback lock 4. thread 1 started running the lambda (delay then getCounter(a)) 5. thread 2 started unregistering dynamic counter b 6. thread 2 lock the whole map 7. thread 2 waits here (Waiting on cb lock) 8. thread 1 calls getCounter(a), which is blocked on the map lock. Reviewed By: andriigrynenko Differential Revision: D53455516 fbshipit-source-id: db172661d50fe568111f6b0f82b98b1f69b388ba
- Loading branch information