From: Lennart Poettering Date: Wed, 30 Oct 2019 15:37:42 +0000 (+0100) Subject: sd-event: don't invalidate source type on disconnect X-Git-Tag: v244-rc1~126^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f59825595182d70b9ead238d1e885d0db99cc201;p=thirdparty%2Fsystemd.git sd-event: don't invalidate source type on disconnect This fixes fd closing if fd ownership is requested. --- diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index ee10728ece2..d93d2f40469 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -771,11 +771,13 @@ static void source_disconnect(sd_event_source *s) { event = s->event; - s->type = _SOURCE_EVENT_SOURCE_TYPE_INVALID; s->event = NULL; LIST_REMOVE(sources, event->sources, s); event->n_sources--; + /* Note that we don't invalidate the type here, since we still need it in order to close the fd or + * pidfd associated with this event source, which we'll do only on source_free(). */ + if (!s->floating) sd_event_unref(event); }