Commit bc5cb2ef authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the min/mix param fields double



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4495 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 8c8c7eda
...@@ -92,46 +92,79 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) ...@@ -92,46 +92,79 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg)
cli_out(cli, "%u", *dst); cli_out(cli, "%u", *dst);
} }
/*--------------------------------------------------------------------*/
void
tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg)
{
volatile unsigned *dest;
dest = par->priv;
tweak_generic_timeout(cli, dest, arg);
}
static void static void
tweak_generic_timeout_double(struct cli *cli, volatile double *dst, tweak_timeout_double(struct cli *cli, const struct parspec *par,
const char *arg) const char *arg)
{ {
volatile double *dest;
double u; double u;
dest = par->priv;
if (arg != NULL) { if (arg != NULL) {
u = strtod(arg, NULL); u = strtod(arg, NULL);
if (u < 0) { if (u < par->min) {
cli_out(cli, cli_out(cli,
"Timeout must be greater or equal to zero\n"); "Timeout must be greater or equal to %.g\n",
par->min);
cli_result(cli, CLIS_PARAM); cli_result(cli, CLIS_PARAM);
return; return;
} }
*dst = u; if (u > par->max) {
cli_out(cli,
"Timeout must be less than or equal to %.g\n",
par->max);
cli_result(cli, CLIS_PARAM);
return;
}
*dest = u;
} else } else
cli_out(cli, "%f", *dst); cli_out(cli, "%.6f", *dest);
} }
#if 0
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void
tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg)
{
volatile unsigned *dest;
dest = par->priv;
tweak_generic_timeout(cli, dest, arg);
}
static void static void
tweak_timeout_double(struct cli *cli, const struct parspec *par, tweak_generic_double(struct cli *cli, const struct parspec *par,
const char *arg) const char *arg)
{ {
volatile double *dest; volatile double *dest;
double u;
dest = par->priv; dest = par->priv;
tweak_generic_timeout_double(cli, dest, arg); if (arg != NULL) {
u = strtod(arg, NULL);
if (u < par->min) {
cli_out(cli,
"Must be greater or equal to %.g\n",
par->min);
cli_result(cli, CLIS_PARAM);
return;
}
if (u > par->max) {
cli_out(cli,
"Must be less than or equal to %.g\n",
par->max);
cli_result(cli, CLIS_PARAM);
return;
}
*dest = u;
} else
cli_out(cli, "%f", *dest);
} }
#endif
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
...@@ -213,7 +246,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) ...@@ -213,7 +246,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg)
volatile unsigned *dest; volatile unsigned *dest;
dest = par->priv; dest = par->priv;
tweak_generic_uint(cli, dest, arg, par->umin, par->umax); tweak_generic_uint(cli, dest, arg, (uint)par->min, (uint)par->max);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
...@@ -551,7 +584,7 @@ static const struct parspec input_parspec[] = { ...@@ -551,7 +584,7 @@ static const struct parspec input_parspec[] = {
0, 0,
"on", "bool" }, "on", "bool" },
{ "fetch_chunksize", { "fetch_chunksize",
tweak_uint, &master.fetch_chunksize, 4, UINT_MAX / 1024, tweak_uint, &master.fetch_chunksize, 4, UINT_MAX / 1024.,
"The default chunksize used by fetcher. " "The default chunksize used by fetcher. "
"This should be bigger than the majority of objects with " "This should be bigger than the majority of objects with "
"short TTLs.\n" "short TTLs.\n"
......
...@@ -61,7 +61,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, ...@@ -61,7 +61,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par,
{ {
tweak_generic_uint(cli, &master.wthread_min, arg, tweak_generic_uint(cli, &master.wthread_min, arg,
par->umin, master.wthread_max); (unsigned)par->min, master.wthread_max);
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -37,8 +37,8 @@ struct parspec { ...@@ -37,8 +37,8 @@ struct parspec {
const char *name; const char *name;
tweak_t *func; tweak_t *func;
volatile void *priv; volatile void *priv;
unsigned umin; double min;
unsigned umax; double max;
const char *descr; const char *descr;
int flags; int flags;
#define DELAYED_EFFECT 1 #define DELAYED_EFFECT 1
......
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