-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple deadlock detector for require locks.
This detector works only with two threads, using the following heuristic: 1. If the lock is already acquired, obtain its owner thread. 2. Check if the owner thread is waiting on a lock. 3. If the lock the owner is waiting on is held by the current thread, raise an error. 4. If there's no owner and no deadlock, try to lock the thread for 500ms + rand(100)ms. 5. If the file has been locked, return success. 6. Otherwise, start over at 1. We may want a more advanced detector that can handle arbitrarily many threads, but it would be much heavier and require scanning all threads in the system, including those unrelated to the current program and those not actually trying to require files. See #3341.
Showing
1 changed file
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters