diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-03-15 21:21:38 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-03-15 21:21:38 +0100 |
commit | 0ac10822732008aa2c0af7a0499c838446ac0a82 (patch) | |
tree | f501494a0c636f67ebb2d558b328843242472384 /src | |
parent | 8f7a3c1402a8de36b2c63935358a53510d2fe7c1 (diff) |
cgroup: don't recheck all the time whether the systemd hierarchy is mounted, to make strace outputs nicer and save a few stat()s
Diffstat (limited to 'src')
-rw-r--r-- | src/cgroup-util.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cgroup-util.c b/src/cgroup-util.c index bbadc789a1..090573bd31 100644 --- a/src/cgroup-util.c +++ b/src/cgroup-util.c @@ -484,6 +484,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch const char *p; char *mp; int r; + static __thread bool good = false; assert(controller); assert(fs); @@ -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) return -ENOMEM; - if ((r = path_is_mount_point(mp)) <= 0) { - free(mp); - return r < 0 ? r : -ENOENT; + if (!good) { + if ((r = path_is_mount_point(mp)) <= 0) { + free(mp); + return r < 0 ? r : -ENOENT; + } + + /* Cache this to save a few stat()s */ + good = true; } if (path && suffix) |