summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-10-30 02:45:10 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-10-30 02:45:10 +0000
commitdec824965a7de11d9973b93c5288156da4541f74 (patch)
treee0f449d66b6c8931e3de8741e9dec78c8c773aaa /lib/libpthread
parenta88be7dca6d06ec3b589cea5315442ba2ae49af0 (diff)
Don't use TAILQ_NEXT() on an element that has been removed. Similar to
otto@'s diff for uvm_aobj.c. Identical to a diff canacar@ developed independantly. ok brad@ 'looks correct' fgsch@
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/uthread/uthread_kern.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c
index 30a5a58d697..0210a4b3ecf 100644
--- a/lib/libpthread/uthread/uthread_kern.c
+++ b/lib/libpthread/uthread/uthread_kern.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_kern.c,v 1.30 2005/01/28 20:35:49 marc Exp $ */
+/* $OpenBSD: uthread_kern.c,v 1.31 2005/10/30 02:45:09 krw Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -589,7 +589,7 @@ _thread_kern_poll(int wait_reqd)
int kern_pipe_added = 0;
int nfds = 0;
int timeout_ms = 0;
- struct pthread *pthread;
+ struct pthread *pthread, *next;
struct timespec ts;
struct timeval tv;
@@ -670,7 +670,8 @@ _thread_kern_poll(int wait_reqd)
}
PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
+ for (pthread = TAILQ_FIRST(&_workq); pthread != NULL; pthread = next) {
+ next = TAILQ_NEXT(pthread, qe);
switch (pthread->state) {
case PS_SPINBLOCK:
/*
@@ -782,7 +783,9 @@ _thread_kern_poll(int wait_reqd)
* _poll syscall:
*/
PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
+ for (pthread = TAILQ_FIRST(&_workq); pthread != NULL;
+ pthread = next) {
+ next = TAILQ_NEXT(pthread, qe);
switch (pthread->state) {
case PS_SPINBLOCK:
/*
@@ -876,7 +879,9 @@ _thread_kern_poll(int wait_reqd)
* that is now available.
*/
PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
+ for (pthread = TAILQ_FIRST(&_workq); pthread != NULL;
+ pthread = next) {
+ next = TAILQ_NEXT(pthread, qe);
if (pthread->state == PS_SPINBLOCK) {
/*
* If the lock is available, let the thread run.