summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrad <brad@openbsd.org>2004-04-09 23:57:17 +0000
committerbrad <brad@openbsd.org>2004-04-09 23:57:17 +0000
commite8530cdf9b41c13b3e2adc3376e0b8eea00149be (patch)
tree47234e2836898d4db2a34e1f58784252fa9450c7
parentremove old libc_r related chunk of the Makefile (diff)
downloadwireguard-openbsd-e8530cdf9b41c13b3e2adc3376e0b8eea00149be.tar.xz
wireguard-openbsd-e8530cdf9b41c13b3e2adc3376e0b8eea00149be.zip
When poll(2)'ing for readability or writability of a file descriptor
on behalf of a thread, we should check the POLLERR, POLLHUP, and POLLNVAL flags as well to wake up the thread in these cases. From: FreeBSD's libc_r ok marc@
-rw-r--r--lib/libpthread/uthread/uthread_kern.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libpthread/uthread/uthread_kern.c b/lib/libpthread/uthread/uthread_kern.c
index ef9d87957b0..c14810d0943 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.27 2003/05/13 16:49:32 marc Exp $ */
+/* $OpenBSD: uthread_kern.c,v 1.28 2004/04/09 23:57:17 brad Exp $ */
/*
* Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -795,7 +795,9 @@ _thread_kern_poll(int wait_reqd)
/* File descriptor read wait: */
case PS_FDR_WAIT:
if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLRDNORM)) {
+ (_thread_pfd_table[nfds].revents
+ & (POLLRDNORM|POLLERR|POLLHUP|POLLNVAL))
+ != 0) {
PTHREAD_WAITQ_CLEARACTIVE();
PTHREAD_WORKQ_REMOVE(pthread);
PTHREAD_NEW_STATE(pthread,PS_RUNNING);
@@ -807,7 +809,9 @@ _thread_kern_poll(int wait_reqd)
/* File descriptor write wait: */
case PS_FDW_WAIT:
if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLWRNORM)) {
+ (_thread_pfd_table[nfds].revents
+ & (POLLWRNORM|POLLERR|POLLHUP|POLLNVAL))
+ != 0) {
PTHREAD_WAITQ_CLEARACTIVE();
PTHREAD_WORKQ_REMOVE(pthread);
PTHREAD_NEW_STATE(pthread,PS_RUNNING);