diff options
author | 2005-10-30 02:45:09 +0000 | |
---|---|---|
committer | 2005-10-30 02:45:09 +0000 | |
commit | ecfd73d4636c2ad9c4b70265c0aa713e16cd2940 (patch) | |
tree | f937b75a72947d731631cb954c8c6058b00afea8 /lib/libpthread | |
parent | mention control socket fallback behaviour, reported by tryponraj AT gmail.com (diff) | |
download | wireguard-openbsd-ecfd73d4636c2ad9c4b70265c0aa713e16cd2940.tar.xz wireguard-openbsd-ecfd73d4636c2ad9c4b70265c0aa713e16cd2940.zip |
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.c | 15 |
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. |