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

Fix a regression in panic output.

Update test-case to exercise more of the panic formatter.
parent 90846c4a
......@@ -45,7 +45,6 @@ volatile struct params *cache_param;
* the thread. This is used for panic messages.
*/
static pthread_key_t sp_key;
static pthread_key_t req_key;
void
......@@ -126,7 +125,6 @@ child_main(void)
cache_param = heritage.param;
AZ(pthread_key_create(&sp_key, NULL));
AZ(pthread_key_create(&req_key, NULL));
AZ(pthread_key_create(&name_key, NULL));
......
......@@ -182,12 +182,12 @@ pan_vcl(const struct VCL_conf *vcl)
{
int i;
VSB_printf(pan_vsp, " vcl = {\n");
VSB_printf(pan_vsp, " srcname = {\n");
VSB_printf(pan_vsp, " vcl = {\n");
VSB_printf(pan_vsp, " srcname = {\n");
for (i = 0; i < vcl->nsrc; ++i)
VSB_printf(pan_vsp, " \"%s\",\n", vcl->srcname[i]);
VSB_printf(pan_vsp, " },\n");
VSB_printf(pan_vsp, " \"%s\",\n", vcl->srcname[i]);
VSB_printf(pan_vsp, " },\n");
VSB_printf(pan_vsp, " },\n");
}
......@@ -224,7 +224,7 @@ pan_busyobj(const struct busyobj *bo)
pan_http("bereq", bo->bereq, 4);
if (bo->beresp->ws != NULL)
pan_http("beresp", bo->beresp, 4);
VSB_printf(pan_vsp, " }\n");
}
/*--------------------------------------------------------------------*/
......@@ -272,7 +272,7 @@ pan_req(const struct req *req)
pan_ws(req->ws, 2);
pan_http("req", req->http, 2);
if (req->resp->ws != NULL)
pan_http("resp", req->resp, 4);
pan_http("resp", req->resp, 2);
if (VALID_OBJ(req->vcl, VCL_CONF_MAGIC))
pan_vcl(req->vcl);
......@@ -293,10 +293,10 @@ pan_sess(const struct sess *sp)
{
const char *stp;
VSB_printf(pan_vsp, "sp = %p {\n", sp);
VSB_printf(pan_vsp, " fd = %d, id = %u,\n",
VSB_printf(pan_vsp, " sp = %p {\n", sp);
VSB_printf(pan_vsp, " fd = %d, id = %u,\n",
sp->fd, sp->vsl_id & VSL_IDENTMASK);
VSB_printf(pan_vsp, " client = %s %s,\n",
VSB_printf(pan_vsp, " client = %s %s,\n",
sp->addr ? sp->addr : "?.?.?.?",
sp->port ? sp->port : "?");
switch (sp->sess_step) {
......@@ -306,11 +306,11 @@ pan_sess(const struct sess *sp)
default: stp = NULL;
}
if (stp != NULL)
VSB_printf(pan_vsp, " step = %s,\n", stp);
VSB_printf(pan_vsp, " step = %s,\n", stp);
else
VSB_printf(pan_vsp, " step = 0x%x,\n", sp->sess_step);
VSB_printf(pan_vsp, " step = 0x%x,\n", sp->sess_step);
VSB_printf(pan_vsp, "},\n");
VSB_printf(pan_vsp, " },\n");
}
/*--------------------------------------------------------------------*/
......
......@@ -134,6 +134,7 @@ ses_pool_task(struct worker *wrk, void *arg)
sp = req->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
THR_SetRequest(req);
AZ(wrk->aws->r);
wrk->lastused = NAN;
CNT_Session(wrk, req);
......@@ -143,6 +144,7 @@ ses_pool_task(struct worker *wrk, void *arg)
if (wrk->vcl != NULL)
VCL_Rel(&wrk->vcl);
}
THR_SetRequest(NULL);
}
/*--------------------------------------------------------------------
......@@ -315,7 +317,6 @@ ses_GetReq(struct sess *sp)
AN(req);
req->magic = REQ_MAGIC;
req->sp = sp;
THR_SetRequest(req);
e = (char*)req + sz;
p = (char*)(req + 1);
......@@ -374,7 +375,6 @@ SES_ReleaseReq(struct req *req)
VSL_Flush(req->vsl, 0);
req->sp = NULL;
MPL_Free(pp->mpl_req, req);
THR_SetRequest(NULL);
}
/*--------------------------------------------------------------------
......
......@@ -4,7 +4,15 @@ server s1 {
rxreq
txresp -hdr "Foo: bar" -body "abcdef\n"
rxreq
txresp -hdr "Panic: please" -body "012345\n"
txresp -hdr "Panic: fetch" -body "012345\n"
close
sema r1 sync 2
accept
rxreq
txresp -hdr "Foo: bar" -body "abcdef\n"
rxreq
txresp -hdr "Panic: deliver" -body "012345\n"
close
sema r1 sync 2
......@@ -17,8 +25,13 @@ varnish v1 -storage "-smalloc,1m" -vcl+backend {
import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so";
sub vcl_fetch {
if (beresp.http.panic == "fetch") {
debug.panic("Had Panic header: " + beresp.http.panic);
}
}
sub vcl_deliver {
if (resp.http.panic) {
if (resp.http.panic == "deliver") {
debug.panic("Had Panic header: " + resp.http.panic);
}
}
......@@ -46,6 +59,23 @@ sema r1 sync 2
delay 0.5
client c1 {
txreq -url "/"
rxresp
txreq -url "/foo"
# Don't expect answer, the server crashed.
} -run
varnish v1 -wait-stopped
varnish v1 -cliok "panic.show"
varnish v1 -cliok "panic.clear"
varnish v1 -clierr 300 "panic.clear"
varnish v1 -cliok "start"
varnish v1 -wait-running
sema r1 sync 2
delay 0.5
client c1 {
txreq -url "/"
rxresp
......
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