tubik: Correct use of flags_cond and version_cond
authorAndrew Deason <adeason@sinenomine.net>
Thu, 1 Apr 2010 21:42:25 +0000 (16:42 -0500)
committerDerrick Brashear <shadow@dementia.org>
Fri, 2 Apr 2010 03:39:42 +0000 (20:39 -0700)
commitaf5923c0507f45fc4124ed9ae5ac5ed014923034
treea964a0304daaed1efc90651a82ae6b02a5d287c3
parent5a7d6da52573aeb5ca062e3458ea7c375ed28054
tubik: Correct use of flags_cond and version_cond

Waiters of flags_cond and version_cond were not doing so correctly;
the correct way is to acquire a lock prior to their respective checks,
and atomically drop/acquire that lock with pthread_cond_wait.
Otherwise, we could miss a wakeup if a flag changed between our check
and when we wait.

To make this possible, make versionLock a normal pthread mutex in
AFS_PTHREAD_ENV, so it is a lock we can pass to pthread_cond_wait.
Make the waiters pass versionLock to pthread_cond_wait, and eliminate
flags_mutex and version_mutex.

Change-Id: Id33a72182b907d069e342cb049e23868ab2f7eb9
Reviewed-on: http://gerrit.openafs.org/1681
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/ubik/ubik.c
src/ubik/ubik.p.h