Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
	* spinlock.c (__pthread_unlock): Don"t crash if called for an
	untaken mutex.  Reported by Ruslan V. Brushkoff <rus@Snif.Te.Net.UA>.
  • Loading branch information
Ulrich Drepper committed Dec 14, 1998
1 parent 60876a7 commit fbaf6e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions linuxthreads/ChangeLog
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
8 changes: 5 additions & 3 deletions linuxthreads/spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fbaf6e7

Please sign in to comment.