fix pthread_cond_wait cancellation race
authorRich Felker <dalias@aerifal.cx>
Mon, 23 Feb 2015 03:07:50 +0000 (22:07 -0500)
committerRich Felker <dalias@aerifal.cx>
Mon, 23 Feb 2015 03:07:50 +0000 (22:07 -0500)
commit8741ffe625363a553e8f509dc3ca7b071bdbab47
treef917a4e8ce76450e2e956b051912cb9861fd9701
parent102f6a01e249ce4495f1119ae6d963a2a4a53ce5
fix pthread_cond_wait cancellation race

it's possible that signaling a waiter races with cancellation of that
same waiter. previously, cancellation was acted upon, causing the
signal to be consumed with no waiter returning. by using the new
masked cancellation state, it's possible to refuse to act on the
cancellation request and instead leave it pending.

to ease review and understanding of the changes made, this commit
leaves the unwait function, which was previously the cancellation
cleanup handler, in place. additional simplifications could be made by
removing it.
src/thread/pthread_cond_timedwait.c