]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-event: ref event loop while in sd_event_prepare() ot sd_event_run()
authorLennart Poettering <lennart@poettering.net>
Mon, 23 Nov 2020 14:38:00 +0000 (15:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Dec 2020 14:10:50 +0000 (15:10 +0100)
commitf814c871e65df8552a055dd887bc94b074037833
treecf8f4e8aa41b0ca041f63e8de6f6f76804fd8e1c
parente6a7bee538f6638c2d5ca2afc66bf47cba3f075c
sd-event: ref event loop while in sd_event_prepare() ot sd_event_run()

sd_event_prepare() invokes callbacks that might drop the last user ref
on our event loop. Let's make sure we keep an explicit ref around it, so
that we won't end up with an invalid pointer. Similar in sd_event_run().

Basically, any function that is publically callable that might end up
invoking callbacks should ref the relevant objects to be protected
against callbacks destroying these objects while we still want to access
them. We did this correctly in sd_event_dispatch() and sd_event_loop(),
but these are not the only ones which are callable from the outside.
src/libsystemd/sd-event/sd-event.c