dryang / rpms / systemd

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