mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-26 10:03:40 +03:00
cgroup: don't recheck all the time whether the systemd hierarchy is mounted, to make strace outputs nicer and save a few stat()s
This commit is contained in:
parent
8f7a3c1402
commit
0ac1082273
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user