b7dd4d
From e48586dcfa66731a353ecc832e43fab75559e2cf Mon Sep 17 00:00:00 2001
4262b8
From: Lennart Poettering <lennart@poettering.net>
4262b8
Date: Wed, 30 Oct 2019 16:37:42 +0100
4262b8
Subject: [PATCH] sd-event: don't invalidate source type on disconnect
4262b8
4262b8
This fixes fd closing if fd ownership is requested.
4262b8
4262b8
(cherry picked from commit f59825595182d70b9ead238d1e885d0db99cc201)
4262b8
b7dd4d
Resolves: #2115396
4262b8
---
4262b8
 src/libsystemd/sd-event/sd-event.c | 4 +++-
4262b8
 1 file changed, 3 insertions(+), 1 deletion(-)
4262b8
4262b8
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
4262b8
index 0adfdd9e1a..09d4584bf9 100644
4262b8
--- a/src/libsystemd/sd-event/sd-event.c
4262b8
+++ b/src/libsystemd/sd-event/sd-event.c
4262b8
@@ -1104,11 +1104,13 @@ static void source_disconnect(sd_event_source *s) {
4262b8
 
4262b8
         event = s->event;
4262b8
 
4262b8
-        s->type = _SOURCE_EVENT_SOURCE_TYPE_INVALID;
4262b8
         s->event = NULL;
4262b8
         LIST_REMOVE(sources, event->sources, s);
4262b8
         event->n_sources--;
4262b8
 
4262b8
+        /* Note that we don't invalidate the type here, since we still need it in order to close the fd or
4262b8
+         * pidfd associated with this event source, which we'll do only on source_free(). */
4262b8
+
4262b8
         if (!s->floating)
4262b8
                 sd_event_unref(event);
4262b8
 }