]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
sysdeps-unix: Diagnose failure to open /proc/self/oom_score_adj
authorSimon McVittie <smcv@collabora.com>
Mon, 21 Feb 2022 16:07:26 +0000 (16:07 +0000)
committerSimon McVittie <smcv@collabora.com>
Tue, 22 Feb 2022 19:31:42 +0000 (19:31 +0000)
Previously, we silently ignored this, but now that we're more careful
about the contexts in which we try to reset the OOM score and whether
we log failures as a warning, we can let the dbus-daemon-launch-helper
show a message if it can't write there.

Signed-off-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-sysdeps-util-unix.c

index 397ed20a93bd6cadd05e2e566287861bf9fbbf9c..314ce64babef7411f61aefe8a577593a7a2065fa 100644 (file)
@@ -1690,12 +1690,19 @@ _dbus_reset_oom_score_adj (const char **error_str_p)
       /* Success */
       ret = TRUE;
     }
-  else
+  else if (errno == ENOENT)
     {
-      /* TODO: Historically we ignored this error, although ideally we
-       * would diagnose it */
+      /* If /proc/self/oom_score_adj doesn't exist, assume the kernel
+       * doesn't support this feature and ignore it. */
       ret = TRUE;
     }
+  else
+    {
+      ret = FALSE;
+      error_str = "open(/proc/self/oom_score_adj)";
+      saved_errno = errno;
+      goto out;
+    }
 
 out:
   if (fd >= 0)