Commit 1ed2adc1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Merge branch 'master' of github.com:varnishcache/varnish-cache

parents 30786d67 110d0732
......@@ -387,28 +387,27 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs)
}
if (vs == VCL_STATE_AUTO) {
now = VTIM_mono();
vs = vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD;
vs = (vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD);
if (vp->go_cold > 0 && vp->state == VCL_STATE_AUTO &&
vp->go_cold + mgt_param.vcl_cooldown < now)
vs = VCL_STATE_COLD;
}
assert(vs != VCL_STATE_AUTO);
warm = vs == VCL_STATE_WARM ? 1 : 0;
warm = (vs == VCL_STATE_WARM ? 1 : 0);
if (vp->warm == warm)
return (0);
vp->warm = warm;
if (vp->warm == 0)
vp->go_cold = 0;
if (!MCH_Running())
if (!MCH_Running()) {
vp->warm = warm;
if (vp->warm == 0)
vp->go_cold = 0;
return (0);
}
i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n",
vp->name, vp->warm, vp->state);
vp->name, warm, vp->state);
if (i && cli != NULL) {
VCLI_SetResult(cli, status);
VCLI_Out(cli, "%s", p);
......@@ -416,8 +415,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs)
MGT_Complain(C_ERR,
"Please file ticket: VCL poker problem: "
"'vcl.state %s %d%s' -> %03d '%s'",
vp->name, vp->warm, vp->state, i, p);
vp->name, warm, vp->state, i, p);
} else {
/* Success, update mgt's VCL state to reflect child's
state */
vp->warm = warm;
if (vp->warm == 0)
vp->go_cold = 0;
}
free(p);
return (i);
}
......
......@@ -90,4 +90,5 @@ varnish v1 -clierr 300 "vcl.state vcl1 warm"
# A warm-up failure can also fail a child start
varnish v1 -cliok stop
varnish v1 -cliok "vcl.state vcl1 warm"
varnish v1 -clierr 300 start
......@@ -82,6 +82,7 @@ struct varnish {
unsigned vsl_tag_count[256];
volatile int vsl_rec;
volatile int vsl_idle;
};
#define NONSENSE "%XJEIFLH|)Xspa8P"
......@@ -182,6 +183,16 @@ wait_running(const struct varnish *v)
* Varnishlog gatherer thread
*/
static void
vsl_catchup(const struct varnish *v)
{
int vsl_idle;
vsl_idle = v->vsl_idle;
while (vsl_idle == v->vsl_idle)
VTIM_sleep(0.1);
}
static void *
varnishlog_thread(void *priv)
{
......@@ -209,11 +220,15 @@ varnishlog_thread(void *priv)
if (c == NULL) {
VTIM_sleep(0.1);
if (VSM_Open(vsm)) {
vtc_log(v->vl, 3, "vsm|%s",
VSM_Error(vsm));
VSM_ResetError(vsm);
continue;
}
c = VSL_CursorVSM(vsl, vsm, opt);
if (c == NULL) {
vtc_log(v->vl, 3, "vsl|%s",
VSL_Error(vsl));
VSL_ResetError(vsl);
continue;
}
......@@ -245,6 +260,7 @@ varnishlog_thread(void *priv)
}
if (i == 0) {
/* Nothing to do but wait */
v->vsl_idle++;
VTIM_sleep(0.1);
} else if (i == -2) {
/* Abandoned - try reconnect */
......@@ -1050,6 +1066,10 @@ varnish_expect(const struct varnish *v, char * const *av)
* style pattern (ie: fnmatch(3)) as used in shell filename expansion.
* To see all counters use pattern "*", to see all counters about
* requests use "*req*".
*
* \-vsl_catchup
* Wait until the logging thread has idled to make sure that all
* the generated log is flushed
*/
void
......@@ -1205,6 +1225,10 @@ cmd_varnish(CMD_ARGS)
varnish_wait(v);
continue;
}
if (!strcmp(*av, "-vsl_catchup")) {
vsl_catchup(v);
continue;
}
vtc_fatal(v->vl, "Unknown varnish argument: %s", *av);
}
}
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