tevent: add tevent_common_fd_mpx infrastructure
authorStefan Metzmacher <metze@samba.org>
Wed, 9 Nov 2022 21:48:10 +0000 (22:48 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 13 Oct 2023 09:49:33 +0000 (09:49 +0000)
commitb328e990651a3182bba3e4e8d8b91eed457bd8a1
treeb6685d0baf0e92b4d16a74248ad2d1221a207dc5
parent95d6600a0668b8abac53cbe2085236b31d652b66
tevent: add tevent_common_fd_mpx infrastructure

Backends may require to map individual tevent_fd instances to
a single low level kernel state (e.g. for epoll).

This generic infrastructure adds helper functions using
a generic (sub)part of struct tevent_fd.

The new code will allow us to support more than 2 tevent_fd
instances per fd, which makes sure all backends can provide
a similar behavior. This will be important when we add
TEVENT_FD_ERROR as a 3rd kind of fd event.

The aim is to use this in order to replace the limited implementation
we already have in tevent_epoll.c.

As these helpers are typically called from within
'void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags)'
there's no way to report errors. So in order avoid additional
error handling complexity the helpers try to avoid
any allocations which may fail. It also means the logic in
tevent_epoll.c doesn't have to change much.

These are implemented as static line functions in order to avoid
the function call overhead, which showed up in profiles of the
early implementation.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/tevent/tevent_epoll.c
lib/tevent/tevent_fd.c
lib/tevent/tevent_internal.h
lib/tevent/tevent_poll.c