Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Fix a race between timed wait callbacks and m...



details:   https://anonhg.NetBSD.org/src/rev/a93403bc4beb
branches:  trunk
changeset: 555676:a93403bc4beb
user:      nathanw <nathanw%NetBSD.org@localhost>
date:      Mon Nov 24 22:54:31 2003 +0000

description:
Fix a race between timed wait callbacks and manual signal/broadcasting
accidentally introduced in rev. 1.5.

Noted by Christian Limpach.

diffstat:

 lib/libpthread/pthread_cond.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 8eba07fdfa1d -r a93403bc4beb lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Mon Nov 24 22:49:08 2003 +0000
+++ b/lib/libpthread/pthread_cond.c     Mon Nov 24 22:54:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.12 2003/11/21 22:08:00 nathanw Exp $        */
+/*     $NetBSD: pthread_cond.c,v 1.13 2003/11/24 22:54:31 nathanw Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.12 2003/11/21 22:08:00 nathanw Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.13 2003/11/24 22:54:31 nathanw Exp $");
 
 #include <errno.h>
 #include <sys/time.h>
@@ -298,11 +298,11 @@
                if (PTQ_EMPTY(&cond->ptc_waiters))
                        cond->ptc_mutex = NULL;
 #endif
-               pthread_spinunlock(self, &cond->ptc_lock);
                if (signaled != NULL) {
                        pthread__sched(self, signaled);
                        PTHREADD_ADD(PTHREADD_COND_WOKEUP);
                }
+               pthread_spinunlock(self, &cond->ptc_lock);
        }
 
        return 0;
@@ -329,9 +329,9 @@
 #ifdef ERRORCHECK
                cond->ptc_mutex = NULL;
 #endif
-               pthread_spinunlock(self, &cond->ptc_lock);
                pthread__sched_sleepers(self, &blockedq);
                PTHREADD_ADD(PTHREADD_COND_WOKEUP);
+               pthread_spinunlock(self, &cond->ptc_lock);
        }
 
        return 0;



Home | Main Index | Thread Index | Old Index