Cuurent cgclassify tool parses /etc/cgrules.conf for every process it gets
on command line. IMHO the rules should be cached.

Signed-off-by: Jan Safranek <[email protected]>
---

 src/tools/cgclassify.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/tools/cgclassify.c b/src/tools/cgclassify.c
index 74d5bec..82eb143 100644
--- a/src/tools/cgclassify.c
+++ b/src/tools/cgclassify.c
@@ -78,7 +78,7 @@ int change_group_based_on_rule(pid_t pid)
        }
 
        /* Change the cgroup by determining the rules */
-       ret = cgroup_change_cgroup_flags(euid, egid, procname, pid, 0);
+       ret = cgroup_change_cgroup_flags(euid, egid, procname, pid, 
CGFLAG_USECACHE);
        if (ret) {
                fprintf(stderr, "Error: change of cgroup failed for"
                " pid %d: %s\n", pid, cgroup_strerror(ret));
@@ -143,6 +143,16 @@ int main(int argc, char *argv[])
                return ret;
        }
 
+       if (!cg_specified) {
+               ret = cgroup_init_rules_cache();
+               if (ret) {
+                       fprintf(stderr, "Error: libcgroup failed to "
+                                       "initialize rules cache, %s\n",
+                                       cgroup_strerror(ret));
+                       return ret;
+               }
+       }
+
        for (i = optind; i < argc; i++) {
                pid = (uid_t) atoi(argv[i]);
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to