[systemd-devel] [RFC 01/12] event: allow EPOLLET as event flag
Lennart Poettering
lennart at poettering.net
Wed Nov 27 13:46:09 PST 2013
On Wed, 27.11.13 19:48, David Herrmann (dh.herrmann at gmail.com) wrote:
Looks obvious. Applied.
> EPOLLET enables edge-triggered mode (see epoll(7) for more). For most
> use-cases, level-triggered is just fine, but for master-TTYs we need
> edge-triggered to catch EPOLLHUP. master-TTYs signal EPOLLHUP if no client
> is connected, but a client may connect some time later (same happens
> during vhangup(2)).
>
> However, epoll doesn't allow masking EPOLLHUP so it's signaled constantly.
> To avoid this, edge-triggered mode is needed.
> ---
> src/libsystemd-bus/sd-event.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
> index 6a6581b..b5ddf71 100644
> --- a/src/libsystemd-bus/sd-event.c
> +++ b/src/libsystemd-bus/sd-event.c
> @@ -584,7 +584,7 @@ _public_ int sd_event_add_io(
>
> assert_return(e, -EINVAL);
> assert_return(fd >= 0, -EINVAL);
> - assert_return(!(events & ~(EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLPRI|EPOLLERR|EPOLLHUP)), -EINVAL);
> + assert_return(!(events & ~(EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET)), -EINVAL);
> assert_return(callback, -EINVAL);
> assert_return(ret, -EINVAL);
> assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
> @@ -1022,7 +1022,7 @@ _public_ int sd_event_source_set_io_events(sd_event_source *s, uint32_t events)
>
> assert_return(s, -EINVAL);
> assert_return(s->type == SOURCE_IO, -EDOM);
> - assert_return(!(events & ~(EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLPRI|EPOLLERR|EPOLLHUP)), -EINVAL);
> + assert_return(!(events & ~(EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET)), -EINVAL);
> assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
> assert_return(!event_pid_changed(s->event), -ECHILD);
>
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list