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