Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread Adjust previous. In the condvar case the wak...



details:   https://anonhg.NetBSD.org/src/rev/81e8f5879445
branches:  trunk
changeset: 934092:81e8f5879445
user:      ad <ad%NetBSD.org@localhost>
date:      Sat Jun 06 22:23:59 2020 +0000

description:
Adjust previous.  In the condvar case the wakeup might already have been
eaten.

diffstat:

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

diffs (38 lines):

diff -r 2fafe2b44d1e -r 81e8f5879445 lib/libpthread/pthread_cond.c
--- a/lib/libpthread/pthread_cond.c     Sat Jun 06 22:23:31 2020 +0000
+++ b/lib/libpthread/pthread_cond.c     Sat Jun 06 22:23:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cond.c,v 1.72 2020/06/04 04:40:01 riastradh Exp $      */
+/*     $NetBSD: pthread_cond.c,v 1.73 2020/06/06 22:23:59 ad Exp $     */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cond.c,v 1.72 2020/06/04 04:40:01 riastradh Exp $");
+__RCSID("$NetBSD: pthread_cond.c,v 1.73 2020/06/06 22:23:59 ad Exp $");
 
 #include <stdlib.h>
 #include <errno.h>
@@ -185,14 +185,14 @@
                pthread_cond_broadcast(cond);
 
                /*
-                * Might have raced with another thread to do the wakeup.
-                * In any case there will be a wakeup for sure.  Eat it and
-                * wait for pt_condwait to clear.
+                * Might have raced with another thread to do the wakeup. 
+                * Wait until released - this thread can't wait on a condvar
+                * again until the data structures are no longer in us.
                 */
-               do {
+               while (self->pt_condwait) {
                        (void)_lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, NULL,
                            0, NULL, NULL);
-               } while (self->pt_condwait);
+               }
        }
 
        /*



Home | Main Index | Thread Index | Old Index