Source-Changes-HG archive

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

[src/netbsd-2-0]: src/lib/libpthread Pullup rev 1.16 (requested by oster in t...



details:   https://anonhg.NetBSD.org/src/rev/2c3ed751508b
branches:  netbsd-2-0
changeset: 562749:2c3ed751508b
user:      jmc <jmc%NetBSD.org@localhost>
date:      Mon Oct 04 05:21:59 2004 +0000

description:
Pullup rev 1.16 (requested by oster in ticket #885)

In cond_wait() and cond_timedwait(), do the ERRORCHECK testing of the
waiters list in all cases, not just on cancellation; there are other
sources of spurious wakeups, such as single-stepping in the debugger.

diffstat:

 lib/libpthread/pthread_cond.c |  26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)

diffs (60 lines):

diff -r 1e20fed47b07 -r 2c3ed751508b lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Mon Oct 04 05:21:07 2004 +0000
+++ b/lib/libpthread/pthread_cond.c     Mon Oct 04 05:21:59 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.14.2.1 2004/05/06 05:34:18 jmc Exp $        */
+/*     $NetBSD: pthread_cond.c,v 1.14.2.2 2004/10/04 05:21:59 jmc Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.14.2.1 2004/05/06 05:34:18 jmc Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.14.2.2 2004/10/04 05:21:59 jmc Exp $");
 
 #include <errno.h>
 #include <sys/time.h>
@@ -145,15 +145,14 @@
        pthread__block(self, &cond->ptc_lock);
        /* Spinlock is unlocked on return */
        pthread_mutex_lock(mutex);
-       if (__predict_false(self->pt_cancel)) {
 #ifdef ERRORCHECK
-               pthread_spinlock(self, &cond->ptc_lock);
-               if (PTQ_EMPTY(&cond->ptc_waiters))
-                       cond->ptc_mutex = NULL;
-               pthread_spinunlock(self, &cond->ptc_lock);
+       pthread_spinlock(self, &cond->ptc_lock);
+       if (PTQ_EMPTY(&cond->ptc_waiters))
+               cond->ptc_mutex = NULL;
+       pthread_spinunlock(self, &cond->ptc_lock);
 #endif         
+       if (__predict_false(self->pt_cancel))
                pthread_exit(PTHREAD_CANCELED);
-       }
 
        SDPRINTF(("(cond wait %p) Woke up on %p, mutex %p\n",
            self, cond, mutex));
@@ -236,15 +235,14 @@
        SDPRINTF(("(cond timed wait %p) %s\n",
            self, (retval == ETIMEDOUT) ? "(timed out)" : ""));
        pthread_mutex_lock(mutex);
-       if (__predict_false(self->pt_cancel)) {
 #ifdef ERRORCHECK
-               pthread_spinlock(self, &cond->ptc_lock);
-               if (PTQ_EMPTY(&cond->ptc_waiters))
-                       cond->ptc_mutex = NULL;
-               pthread_spinunlock(self, &cond->ptc_lock);
+       pthread_spinlock(self, &cond->ptc_lock);
+       if (PTQ_EMPTY(&cond->ptc_waiters))
+               cond->ptc_mutex = NULL;
+       pthread_spinunlock(self, &cond->ptc_lock);
 #endif         
+       if (__predict_false(self->pt_cancel))
                pthread_exit(PTHREAD_CANCELED);
-       }
 
        return retval;
 }



Home | Main Index | Thread Index | Old Index