Commit 602e6197 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

renovate tackle_warg()



git-svn-id: http://www.varnish-cache.org/svn/trunk@2989 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 18a78f90
...@@ -98,6 +98,19 @@ pick(const struct choice *cp, const char *which, const char *kind) ...@@ -98,6 +98,19 @@ pick(const struct choice *cp, const char *which, const char *kind)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static unsigned long
arg_ul(const char *p)
{
char *q;
unsigned long ul;
ul = strtoul(p, &q, 0);
if (*q != '\0')
ARGV_ERR("Invalid number: \"%s\"\n", p);
return (ul);
}
/*--------------------------------------------------------------------*/
extern struct stevedore sma_stevedore; extern struct stevedore sma_stevedore;
extern struct stevedore smf_stevedore; extern struct stevedore smf_stevedore;
...@@ -224,47 +237,35 @@ usage(void) ...@@ -224,47 +237,35 @@ usage(void)
static void static void
tackle_warg(const char *argv) tackle_warg(const char *argv)
{ {
char **av;
unsigned int u; unsigned int u;
char *ep, *eq;
u = strtoul(argv, &ep, 0); av = ParseArgv(argv, ARGV_COMMA);
if (ep == argv) AN(av);
usage();
while (isspace(*ep))
ep++;
if (u < 1)
usage();
params->wthread_min = u;
if (*ep == '\0') { if (av[0] != NULL)
params->wthread_max = params->wthread_min; ARGV_ERR("%s\n", av[0]);
return;
}
if (*ep != ',') if (av[1] == NULL)
usage();
u = strtoul(++ep, &eq, 0);
if (eq == ep)
usage(); usage();
if (u < params->wthread_min)
u = arg_ul(av[1]);
if (u < 1)
usage(); usage();
while (isspace(*eq)) params->wthread_max = params->wthread_min = u;
eq++;
params->wthread_max = u;
if (*eq == '\0') if (av[2] != NULL) {
return; u = arg_ul(av[2]);
if (u < params->wthread_min)
usage();
params->wthread_max = u;
if (*eq != ',') if (av[3] != NULL) {
usage(); u = arg_ul(av[3]);
u = strtoul(++eq, &ep, 0); params->wthread_timeout = u;
if (ep == eq) }
usage(); }
while (isspace(*ep)) FreeArgv(av);
ep++;
if (*ep != '\0')
usage();
params->wthread_timeout = u;
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment