Commit 6e3c168
committed
Fix race condition in
`block.call(queue.shift) until queue.empty?` isn't thread safe.
If there is one element left in the queue, two or more thread may
see `queue.empty?` return `false` and call the blocking `shift`
ending in a deadlock.
The proper way to synchronize threads with a queue is to close the
queue once no more elements need to be added.
This should fix the occasional `fatal: No live threads left. Deadlock? (fatal)`
failures on CI.rake parse:topgems
1 parent 7367f3c commit 6e3c168
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
67 | 66 | | |
68 | 67 | | |
69 | | - | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
0 commit comments