diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-05-16 22:32:15 -0400 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 8ebe20735880f8eb19b81d25c73abced0550adae (patch) | |
tree | 0206decf7f0991f87ef1aa383a6332e928229760 /src/basic/util.c | |
parent | 25c44173bfee225cca00613c66177bfebf5e49c0 (diff) |
util: add debug logging to system_tasks_max()
We should always do debug logging when we eat up error conditions. Let's
do so here too.
Diffstat (limited to 'src/basic/util.c')
-rw-r--r-- | src/basic/util.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index 396e3d66b..6d85c0a6a 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -499,6 +499,7 @@ uint64_t system_tasks_max(void) { uint64_t a = TASKS_MAX, b = TASKS_MAX; _cleanup_free_ char *root = NULL; + int r; /* Determine the maximum number of tasks that may run on this system. We check three sources to determine this * limit: @@ -509,13 +510,24 @@ uint64_t system_tasks_max(void) { * * And then pick the smallest of the three */ - (void) procfs_tasks_get_limit(&a); + r = procfs_tasks_get_limit(&a); + if (r < 0) + log_debug_errno(r, "Failed to read maximum number of tasks from /proc, ignoring: %m"); - if (cg_get_root_path(&root) >= 0) { + r = cg_get_root_path(&root); + if (r < 0) + log_debug_errno(r, "Failed to determine cgroup root path, ignoring: %m"); + else { _cleanup_free_ char *value = NULL; - if (cg_get_attribute("pids", root, "pids.max", &value) >= 0) - (void) safe_atou64(value, &b); + r = cg_get_attribute("pids", root, "pids.max", &value); + if (r < 0) + log_debug_errno(r, "Failed to read pids.max attribute of cgroup root, ignoring: %m"); + else if (!streq(value, "max")) { + r = safe_atou64(value, &b); + if (r < 0) + log_debug_errno(r, "Failed to parse pids.max attribute of cgroup root, ignoring: %m"); + } } return MIN3(TASKS_MAX, |