r4495 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jan 27 16:14:51 CET 2010
Author: phk
Date: 2010-01-27 16:14:50 +0100 (Wed, 27 Jan 2010)
New Revision: 4495
Modified:
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/mgt_pool.c
trunk/varnish-cache/bin/varnishd/vparam.h
Log:
Make the min/mix param fields double
Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-01-26 22:56:39 UTC (rev 4494)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2010-01-27 15:14:50 UTC (rev 4495)
@@ -92,46 +92,79 @@
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
-tweak_generic_timeout_double(struct cli *cli, volatile double *dst,
+tweak_timeout_double(struct cli *cli, const struct parspec *par,
const char *arg)
{
+ volatile double *dest;
double u;
+ dest = par->priv;
if (arg != NULL) {
u = strtod(arg, NULL);
- if (u < 0) {
+ if (u < par->min) {
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);
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
- 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
-tweak_timeout_double(struct cli *cli, const struct parspec *par,
+tweak_generic_double(struct cli *cli, const struct parspec *par,
const char *arg)
{
volatile double *dest;
+ double u;
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
@@ -213,7 +246,7 @@
volatile unsigned *dest;
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 @@
0,
"on", "bool" },
{ "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. "
"This should be bigger than the majority of objects with "
"short TTLs.\n"
Modified: trunk/varnish-cache/bin/varnishd/mgt_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-01-26 22:56:39 UTC (rev 4494)
+++ trunk/varnish-cache/bin/varnishd/mgt_pool.c 2010-01-27 15:14:50 UTC (rev 4495)
@@ -61,7 +61,7 @@
{
tweak_generic_uint(cli, &master.wthread_min, arg,
- par->umin, master.wthread_max);
+ (unsigned)par->min, master.wthread_max);
}
/*--------------------------------------------------------------------*/
Modified: trunk/varnish-cache/bin/varnishd/vparam.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/vparam.h 2010-01-26 22:56:39 UTC (rev 4494)
+++ trunk/varnish-cache/bin/varnishd/vparam.h 2010-01-27 15:14:50 UTC (rev 4495)
@@ -37,8 +37,8 @@
const char *name;
tweak_t *func;
volatile void *priv;
- unsigned umin;
- unsigned umax;
+ double min;
+ double max;
const char *descr;
int flags;
#define DELAYED_EFFECT 1
More information about the varnish-commit
mailing list