Commit 0ac10822 authored by Lennart Poettering's avatar Lennart Poettering
Browse files

cgroup: don't recheck all the time whether the systemd hierarchy is mounted,...

cgroup: don't recheck all the time whether the systemd hierarchy is mounted, to make strace outputs nicer and save a few stat()s
parent 8f7a3c14
...@@ -484,6 +484,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch ...@@ -484,6 +484,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
const char *p; const char *p;
char *mp; char *mp;
int r; int r;
static __thread bool good = false;
assert(controller); assert(controller);
assert(fs); assert(fs);
...@@ -504,9 +505,14 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch ...@@ -504,9 +505,14 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
if (asprintf(&mp, "/sys/fs/cgroup/%s", p) < 0) if (asprintf(&mp, "/sys/fs/cgroup/%s", p) < 0)
return -ENOMEM; return -ENOMEM;
if ((r = path_is_mount_point(mp)) <= 0) { if (!good) {
free(mp); if ((r = path_is_mount_point(mp)) <= 0) {
return r < 0 ? r : -ENOENT; free(mp);
return r < 0 ? r : -ENOENT;
}
/* Cache this to save a few stat()s */
good = true;
} }
if (path && suffix) if (path && suffix)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment