]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
Cgred service won't start if /etc/cgrules.conf is missing
authorPeter Schiffer <pschiffe@redhat.com>
Tue, 25 Jun 2013 04:47:47 +0000 (06:47 +0200)
committerPeter Schiffer <pschiffe@redhat.com>
Tue, 25 Jun 2013 04:47:47 +0000 (06:47 +0200)
By default, the /etc/cgrules.conf file contains only comments. If this is the case, the cgred service starts without problem. But if /etc/cgrules.conf file is empty or missing, the cgred service won't start, even this case is equivalent with the first one.

This patch allows the cgred service start even when the /etc/cgrules.conf files is empty, or missing.

Signed-off-by: Peter Schiffer <pschiffe@redhat.com>
Acked-by: Jan Safranek <jsafrane@redhat.com>
Acked-by: Ivana Hutarova Varekova <varekova@redhat.com>
scripts/init.d/cgred.in
src/api.c

index 9ff2d9ba06a09f96928454dcec9da6bd6362d8b6..ed757cfacac2d95578fd5d8c740d45dca10e4239 100644 (file)
@@ -73,10 +73,6 @@ start()
                log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
                return 0
        fi
-       if [ ! -s $CGRED_CONF ]; then
-               log_failure_msg "not configured"
-               return 6
-       fi
        if ! grep "^cgroup" /proc/mounts &>/dev/null; then
                echo
                log_failure_msg $"Cannot find cgroups, is cgconfig service running?"
index 98eea29408547b6f7d3f8d369c56fe5d5ac2e946..e5e1959fed082510c9eaecab2773c8c5571e5cd1 100644 (file)
--- a/src/api.c
+++ b/src/api.c
@@ -538,17 +538,6 @@ static int cgroup_parse_rules(bool cache, uid_t muid,
        /* Loop variable. */
        int i = 0;
 
-       /* Open the configuration file. */
-       pthread_rwlock_wrlock(&rl_lock);
-       fp = fopen(CGRULES_CONF_FILE, "re");
-       if (!fp) {
-               cgroup_err("Error: failed to open configuration file %s: %s\n",
-                               CGRULES_CONF_FILE, strerror(errno));
-               last_errno = errno;
-               ret = ECGOTHER;
-               goto unlock;
-       }
-
        /* Determine which list we're using. */
        if (cache)
                lst = &rl;
@@ -559,6 +548,15 @@ static int cgroup_parse_rules(bool cache, uid_t muid,
        if (lst->head)
                cgroup_free_rule_list(lst);
 
+       /* Open the configuration file. */
+       pthread_rwlock_wrlock(&rl_lock);
+       fp = fopen(CGRULES_CONF_FILE, "re");
+       if (!fp) {
+               cgroup_warn("Warning: failed to open configuration file %s: %s\n",
+                               CGRULES_CONF_FILE, strerror(errno));
+               goto unlock;
+       }
+
        /* Now, parse the configuration file one line at a time. */
        cgroup_dbg("Parsing configuration file.\n");
        while (fgets(buff, sizeof(buff), fp) != NULL) {