teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0662-sd-event-take-ref-on-event-loop-object-before-dispat.patch

be0c12
From f025def77efc6bb1473b719e905fa70ed20b08d3 Mon Sep 17 00:00:00 2001
be0c12
From: Michal Sekletar <msekleta@redhat.com>
be0c12
Date: Wed, 8 Sep 2021 15:42:11 +0200
be0c12
Subject: [PATCH] sd-event: take ref on event loop object before dispatching
be0c12
 event sources
be0c12
be0c12
Idea is that all public APIs should take reference on objects that get
be0c12
exposed to user-provided callbacks. We take the reference as a
be0c12
protection from callbacks dropping it. We used to do this also here in
be0c12
sd_event_loop(). However, in cleanup portion of f814c871e6 this was
be0c12
accidentally dropped.
be0c12
be0c12
(cherry picked from commit 9f6ef467818f902fe5369c8e37a39a3901bdcf4f)
be0c12
be0c12
Related: #1970945
be0c12
---
be0c12
 src/libsystemd/sd-event/sd-event.c | 2 +-
be0c12
 1 file changed, 1 insertion(+), 1 deletion(-)
be0c12
be0c12
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
be0c12
index f78da00c3a..47cf93b3f4 100644
be0c12
--- a/src/libsystemd/sd-event/sd-event.c
be0c12
+++ b/src/libsystemd/sd-event/sd-event.c
be0c12
@@ -3838,7 +3838,7 @@ _public_ int sd_event_loop(sd_event *e) {
be0c12
         assert_return(!event_pid_changed(e), -ECHILD);
be0c12
         assert_return(e->state == SD_EVENT_INITIAL, -EBUSY);
be0c12
 
be0c12
-        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
be0c12
+        _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = sd_event_ref(e);
be0c12
 
be0c12
         while (e->state != SD_EVENT_FINISHED) {
be0c12
                 r = sd_event_run(e, (uint64_t) -1);