chiark / gitweb /
Add fd close support to sd_event_source
authorNathaniel McCallum <npmccallum@redhat.com>
Wed, 24 Jan 2018 14:45:48 +0000 (09:45 -0500)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:15 +0000 (07:50 +0200)
commitd776c8ca879216a12abaa39bc17721b071045cd6
tree724d699521b59ab6fe7c917f6ca76d97b3e91e78
parent8e735ec0a1f35b1a92576806404ed722403b7395
Add fd close support to sd_event_source

It is often the case that a file descriptor and its corresponding IO
sd_event_source share a life span. When this is the case, developers will
have to unref the event source and close the file descriptor. Instead, we
can just have the event source take ownership of the file descriptor and
close it when the event source is freed. This is especially useful when
combined with cleanup attributes and sd_event_source_unrefp().

This patch adds two new public functions:

    sd_event_source_get_io_fd_own()
    sd_event_source_set_io_fd_own()
src/libelogind/libelogind.sym
src/libelogind/sd-event/sd-event.c
src/systemd/sd-event.h