]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
log: Log when kmsg is being ratelimited
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 20 Apr 2023 08:43:21 +0000 (10:43 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 20 Apr 2023 11:43:36 +0000 (13:43 +0200)
Let's avoid confusing developers and users when log messages suddenly
stop getting logged to kmsg because of ratelimiting by logging an
additional message if we start ratelimiting log messages to kmsg.

src/basic/log.c

index d0fef3554f506cf643496e7c557392cd799b00c9..4cd2d5a4ab6667fb081e8a95f68a3463cd4716e3 100644 (file)
@@ -553,8 +553,12 @@ static int write_to_kmsg(
         if (kmsg_fd < 0)
                 return 0;
 
-        if (ratelimit_kmsg && !ratelimit_below(&ratelimit))
-                return 0;
+        if (ratelimit_kmsg && !ratelimit_below(&ratelimit)) {
+                if (ratelimit_num_dropped(&ratelimit) > 1)
+                        return 0;
+
+                buffer = "Too many messages being logged to kmsg, ignoring";
+        }
 
         xsprintf(header_priority, "<%i>", level);
         xsprintf(header_pid, "["PID_FMT"]: ", getpid_cached());