Commit bc5e080
committed
Fix potential deadlock in TimeSource::destroy_clock_sub
destroy_clock_sub() held clock_sub_lock_ while calling
clock_executor_thread_.join(). If the executor thread's callback
tried to access state protected by clock_sub_lock_ before exiting,
this would deadlock: main thread waits for executor thread to finish,
executor thread waits for main thread to release the lock.
Fix by moving the thread, executor, and callback group into local
variables under the lock, then releasing the lock before joining.
This ensures the executor thread can complete its final callback
without contending on clock_sub_lock_.
Fixes #2962
Signed-off-by: Pavel Guzenfeld <me@pavelguzenfeld.com>1 parent af78e01 commit bc5e080
1 file changed
+23
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
430 | 448 | | |
431 | | - | |
432 | 449 | | |
433 | 450 | | |
434 | 451 | | |
| |||
0 commit comments