diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-12-14 16:33:50 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-12-14 16:33:50 +0000 |
commit | fbaf6e72d676629c21d00eab5824571b1b26a2b2 (patch) | |
tree | 24eac15a02a6ea5f04df569a4c6519b13612afca /linuxthreads | |
parent | 60876a75445b1b65e4a0ec54e18205a79f79466b (diff) | |
download | glibc-fbaf6e72d676629c21d00eab5824571b1b26a2b2.tar.gz |
Update.
* spinlock.c (__pthread_unlock): Don"t crash if called for an
untaken mutex. Reported by Ruslan V. Brushkoff <rus@Snif.Te.Net.UA>.
Diffstat (limited to 'linuxthreads')
-rw-r--r-- | linuxthreads/ChangeLog | 3 | ||||
-rw-r--r-- | linuxthreads/spinlock.c | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 554e0fb01d..ae024013ff 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,5 +1,8 @@ 1998-12-14 Ulrich Drepper <drepper@cygnus.com> + * spinlock.c (__pthread_unlock): Don"t crash if called for an + untaken mutex. Reported by Ruslan V. Brushkoff <rus@Snif.Te.Net.UA>. + * Examples/ex6.c: Unbuffer stdout and reduce sleep time to reduce overall runtime. diff --git a/linuxthreads/spinlock.c b/linuxthreads/spinlock.c index 00a8691e5b..c8f8f71293 100644 --- a/linuxthreads/spinlock.c +++ b/linuxthreads/spinlock.c @@ -65,9 +65,11 @@ void internal_function __pthread_unlock(struct _pthread_fastlock * lock) again: oldstatus = lock->__status; - if (oldstatus == 1) { - /* No threads are waiting for this lock */ - if (! compare_and_swap(&lock->__status, 1, 0, &lock->__spinlock)) + if (oldstatus == 0 || oldstatus == 1) { + /* No threads are waiting for this lock. Please note that we also + enter this case if the lock is not taken at all. If this wouldn't + be done here we would crash further down. */ + if (! compare_and_swap(&lock->__status, oldstatus, 0, &lock->__spinlock)) goto again; return; } |