]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
daemon-util: introduce notify_remove_fd()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Jan 2026 22:18:56 +0000 (07:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Jan 2026 22:24:54 +0000 (07:24 +0900)
It is equivalent to notify_remove_fd_warn() but logs in debug level on
failure.

src/shared/daemon-util.c
src/shared/daemon-util.h

index ce75faf274fe7b14ba8371e80316bd4dda9c4570..dbd0de6567f0f30bc9e2aa8777e0c30e6e9552ba 100644 (file)
@@ -9,7 +9,7 @@
 #include "string-util.h"
 #include "time-util.h"
 
-int notify_remove_fd_warn(const char *name) {
+static int notify_remove_fd_full(int log_level, const char *name) {
         int r;
 
         assert(name);
@@ -18,13 +18,22 @@ int notify_remove_fd_warn(const char *name) {
                        "FDSTOREREMOVE=1\n"
                        "FDNAME=%s", name);
         if (r < 0)
-                return log_warning_errno(r,
-                                         "Failed to remove file descriptor \"%s\" from the store, ignoring: %m",
-                                         name);
+                return log_full_errno(
+                                log_level, r,
+                                "Failed to remove file descriptor \"%s\" from the store, ignoring: %m",
+                                name);
 
         return 0;
 }
 
+int notify_remove_fd(const char *name) {
+        return notify_remove_fd_full(LOG_DEBUG, name);
+}
+
+int notify_remove_fd_warn(const char *name) {
+        return notify_remove_fd_full(LOG_WARNING, name);
+}
+
 int notify_remove_fd_warnf(const char *format, ...) {
         _cleanup_free_ char *p = NULL;
         va_list ap;
index 708a32985c6c521a521890560cbc11ca806a6322..d0252a8c82f62abd820cf6a723185631a5616f86 100644 (file)
@@ -21,6 +21,7 @@ static inline void notify_on_cleanup(const char **p) {
                 (void) sd_notify(false, *p);
 }
 
+int notify_remove_fd(const char *name);
 int notify_remove_fd_warn(const char *name);
 int notify_remove_fd_warnf(const char *format, ...) _printf_(1, 2);
 int close_and_notify_warn(int fd, const char *name);