On 06/19/2013 02:58 PM, Peter Schiffer wrote:
> 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 <[email protected]>
Acked-By: Jan Safranek <[email protected]>
> ---
> scripts/init.d/cgred.in | 4 ----
> src/api.c | 20 +++++++++-----------
> 2 files changed, 9 insertions(+), 15 deletions(-)
>
> diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in
> index 9ff2d9b..ed757cf 100644
> --- a/scripts/init.d/cgred.in
> +++ b/scripts/init.d/cgred.in
> @@ -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?"
> diff --git a/src/api.c b/src/api.c
> index 98eea29..e5e1959 100644
> --- 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) {
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel