]> err.no Git - systemd/commitdiff
cgroup: don't recheck all the time whether the systemd hierarchy is mounted, to make...
authorLennart Poettering <lennart@poettering.net>
Tue, 15 Mar 2011 20:21:38 +0000 (21:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 15 Mar 2011 20:21:38 +0000 (21:21 +0100)
src/cgroup-util.c

index bbadc789a1651a30a2d995c85f807c704dc41b84..090573bd31ee7d0167e47f7ef3603ee0c6082623 100644 (file)
@@ -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)