diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-06-15 15:29:41 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2020-06-15 15:29:41 +0000 |
commit | 86476d56c2cae894d47711779ba6feee8523ce25 (patch) | |
tree | d8f2c5f42bc09ae30306dd02e4bfcf86b7a5c3ae /sys | |
parent | e4d9693938acba40c0757300ec31349367a49890 (diff) |
Set __EV_HUP when the conditions matching poll(2)'s POLLUP are found.
This is only done in poll-compatibility mode, when __EV_POLL is set.
ok visa@, millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/sys_pipe.c | 6 | ||||
-rw-r--r-- | sys/kern/tty.c | 4 | ||||
-rw-r--r-- | sys/kern/tty_pty.c | 4 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 10 | ||||
-rw-r--r-- | sys/miscfs/fifofs/fifo_vnops.c | 6 | ||||
-rw-r--r-- | sys/sys/event.h | 7 |
6 files changed, 30 insertions, 7 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index fc221bfd8f1..7a05ad0649f 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_pipe.c,v 1.119 2020/04/07 13:27:51 visa Exp $ */ +/* $OpenBSD: sys_pipe.c,v 1.120 2020/06/15 15:29:40 mpi Exp $ */ /* * Copyright (c) 1996 John S. Dyson @@ -967,6 +967,8 @@ filt_piperead(struct knote *kn, long hint) if ((hint & NOTE_SUBMIT) == 0) rw_exit_read(lock); kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) + kn->kn_flags |= __EV_HUP; return (1); } @@ -991,6 +993,8 @@ filt_pipewrite(struct knote *kn, long hint) rw_exit_read(lock); kn->kn_data = 0; kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) + kn->kn_flags |= __EV_HUP; return (1); } kn->kn_data = wpipe->pipe_buffer.size - wpipe->pipe_buffer.cnt; diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 738ca2698df..08b44aff92d 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.156 2020/05/29 04:42:25 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.157 2020/06/15 15:29:40 mpi Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -1155,6 +1155,8 @@ filt_ttyread(struct knote *kn, long hint) splx(s); if (!ISSET(tp->t_cflag, CLOCAL) && !ISSET(tp->t_state, TS_CARR_ON)) { kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) + kn->kn_flags |= __EV_HUP; return (1); } return (kn->kn_data > 0); diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 693abddfd29..97f41437f8d 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.99 2020/05/21 09:34:06 mpi Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.100 2020/06/15 15:29:40 mpi Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -678,6 +678,8 @@ filt_ptcread(struct knote *kn, long hint) if (!ISSET(tp->t_state, TS_CARR_ON)) { kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) + kn->kn_flags |= __EV_HUP; return (1); } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index d6f2eb6ca3c..68685c0d83f 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.244 2020/04/12 16:15:18 anton Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.245 2020/06/15 15:29:40 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -2064,6 +2064,10 @@ filt_soread(struct knote *kn, long hint) #endif /* SOCKET_SPLICE */ if (so->so_state & SS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) { + if (so->so_state & SS_ISDISCONNECTED) + kn->kn_flags |= __EV_HUP; + } kn->kn_fflags = so->so_error; rv = 1; } else if (so->so_error) { /* temporary udp error */ @@ -2102,6 +2106,10 @@ filt_sowrite(struct knote *kn, long hint) kn->kn_data = sbspace(so, &so->so_snd); if (so->so_state & SS_CANTSENDMORE) { kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) { + if (so->so_state & SS_ISDISCONNECTED) + kn->kn_flags |= __EV_HUP; + } kn->kn_fflags = so->so_error; rv = 1; } else if (so->so_error) { /* temporary udp error */ diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index 07ede492f47..9a97752c3f5 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo_vnops.c,v 1.76 2020/04/08 08:07:52 mpi Exp $ */ +/* $OpenBSD: fifo_vnops.c,v 1.77 2020/06/15 15:29:40 mpi Exp $ */ /* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */ /* @@ -559,6 +559,10 @@ filt_fiforead(struct knote *kn, long hint) kn->kn_data = so->so_rcv.sb_cc; if (so->so_state & SS_CANTRCVMORE) { kn->kn_flags |= EV_EOF; + if (kn->kn_flags & __EV_POLL) { + if (so->so_state & SS_ISDISCONNECTED) + kn->kn_flags |= __EV_HUP; + } rv = 1; } else { kn->kn_flags &= ~EV_EOF; diff --git a/sys/sys/event.h b/sys/sys/event.h index c0e7b0846b8..b4539666c9a 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -1,4 +1,4 @@ -/* $OpenBSD: event.h,v 1.41 2020/06/12 09:34:17 mpi Exp $ */ +/* $OpenBSD: event.h,v 1.42 2020/06/15 15:29:40 mpi Exp $ */ /*- * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> @@ -74,7 +74,6 @@ struct kevent { #define EV_DISPATCH 0x0080 /* disable event after reporting */ #define EV_SYSFLAGS 0xF000 /* reserved by system */ -#define __EV_POLL 0x1000 /* match behavior of poll & select */ #define EV_FLAG1 0x2000 /* filter-specific flag */ /* returned values */ @@ -130,6 +129,10 @@ struct klist { #ifdef _KERNEL +/* kernel-only flags */ +#define __EV_POLL 0x1000 /* match behavior of poll & select */ +#define __EV_HUP EV_FLAG1 /* device or socket disconnected */ + #define EVFILT_MARKER 0xf /* placemarker for tailq */ /* |