From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 May 2024 18:02:26 +0000 (+0200) Subject: sd-event: emit a debug line if disabling unreffed source fails X-Git-Tag: v257-rc1~1190^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ca77ee645717bdc98051831883473b62a86c9b0;p=thirdparty%2Fsystemd.git sd-event: emit a debug line if disabling unreffed source fails We can only do a debug log from the library, so let's add that. Callers probably want to provide some hint when that happens, but it's very unlikely so not worth coding in every caller. And drop the now-unnecessary handling in unit_dequeue_rewatch_pids(). --- diff --git a/src/core/unit.c b/src/core/unit.c index 1dea0db3fe2..07ec132f308 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2978,16 +2978,8 @@ int unit_enqueue_rewatch_pids(Unit *u) { } void unit_dequeue_rewatch_pids(Unit *u) { - int r; assert(u); - if (!u->rewatch_pids_event_source) - return; - - r = sd_event_source_set_enabled(u->rewatch_pids_event_source, SD_EVENT_OFF); - if (r < 0) - log_warning_errno(r, "Failed to disable event source for tidying watched PIDs, ignoring: %m"); - u->rewatch_pids_event_source = sd_event_source_disable_unref(u->rewatch_pids_event_source); } diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index a1305ef0149..2388ebe6359 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -474,8 +474,13 @@ _public_ sd_event* sd_event_unref(sd_event *e) { _unused_ _cleanup_(sd_event_unrefp) sd_event *_ref = sd_event_ref(e); _public_ sd_event_source* sd_event_source_disable_unref(sd_event_source *s) { - if (s) - (void) sd_event_source_set_enabled(s, SD_EVENT_OFF); + int r; + + r = sd_event_source_set_enabled(s, SD_EVENT_OFF); + if (r < 0) + log_debug_errno(r, "Failed to disable event source %p (%s): %m", + s, strna(s->description)); + return sd_event_source_unref(s); }