Skip to content

Commit

Permalink
core: Thinkos and typos in set_loadctl_options()
Browse files Browse the repository at this point in the history
With the previous code, it was first of all impossible to set the
most important metric of all; jobs_limit.

Secondly, one could set a limit that was below the jobs_min, or
above jobs_max. We shan't tolerate such foolishness. Considering
how easy it is to change the load control parameters it's no
great chore to set the max and min parameters alongside the
current active limit.

Signed-off-by: Andreas Ericsson <[email protected]>

git-svn-id: https://nagios.svn.sourceforge.net/svnroot/nagios/nagioscore/trunk@2444 5f96b256-904b-4d8d-8c98-d829582c6739
  • Loading branch information
ageric committed Oct 30, 2012
1 parent 33f2fc8 commit 67c103c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion base/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ int set_loadctl_options(char *opts, unsigned int len)
} else if (!strcmp(kv->key, "jobs_min")) {
loadctl.jobs_min = atoi(kv->value);
} else if (!strcmp(kv->key, "jobs_limit")) {
loadctl.jobs_min = atoi(kv->value);
loadctl.jobs_limit = atoi(kv->value);
} else if (!strcmp(kv->key, "check_interval")) {
loadctl.check_interval = strtoul(kv->value, NULL, 10);
} else if (!strcmp(kv->key, "backoff_limit")) {
Expand All @@ -312,6 +312,14 @@ int set_loadctl_options(char *opts, unsigned int len)
return 400;
}
}

/* precedence order is "jobs_min -> jobs_max -> jobs_limit" */
if (loadctl.jobs_max < loadctl.jobs_min)
loadctl.jobs_max = loadctl.jobs_min;
if (loadctl.jobs_limit > loadctl.jobs_max)
loadctl.jobs_limit = loadctl.jobs_max;
if (loadctl.jobs_limit < loadctl.jobs_min)
loadctl.jobs_limit = loadctl.jobs_min;
kvvec_destroy(kvv, 0);
return 0;
}
Expand Down

0 comments on commit 67c103c

Please sign in to comment.