diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-02-26 05:10:13 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-02-26 05:18:59 -0800 |
commit | 29a6c98f522236a9abb9a8f2e83fdf76bc39c614 (patch) | |
tree | 887694954d3f60a33e35196f62e8436a4173fa2b /README | |
parent | 6fabe39ba8841ffe392c9b659505e12edaff43d6 (diff) |
threads: fix cancellation on destroy
Depending on where cancellation was happening, locks were potentially
left held which could result in the next thread being cancelled
deadlocking.
In deferred cancellation, only cancellation points realize the
cancellation.
So one worker thread could realize the cancellation entering say,
pthread_cond_wait, and exit with the associated mutex still held.
The other thread could be in the process of returning from
pthread_cond_wait - past the cancellation point already, and get stuck
in trying to acquire the mutex as pthread_cond_wait does before
returning, because the lock was left held by the other thread.
Instead, use the cleanup handlers to unlock the mutexes, and enable
asynchronous cancellation.
This seems to eliminate the observed occasional deadlocks on destroy.
Diffstat (limited to 'README')
0 files changed, 0 insertions, 0 deletions