Module Name:    src
Committed By:   ad
Date:           Sat Jun  6 22:24:00 UTC 2020

Modified Files:
        src/lib/libpthread: pthread_cond.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/lib/libpthread/pthread_cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/pthread_cond.c
diff -u src/lib/libpthread/pthread_cond.c:1.72 src/lib/libpthread/pthread_cond.c:1.73
--- src/lib/libpthread/pthread_cond.c:1.72	Thu Jun  4 04:40:01 2020
+++ src/lib/libpthread/pthread_cond.c	Sat Jun  6 22:23:59 2020
@@ -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_timedwait(pthread_cond_t *c
 		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);
+		}
 	}
 
 	/*

Reply via email to