[master] 1c82be0 Fix a regression in panic output.
Poul-Henning Kamp
phk at varnish-cache.org
Mon Jun 25 12:11:25 CEST 2012
commit 1c82be0c4664a0311a5c5207764bae9d25fd1023
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jun 25 10:11:03 2012 +0000
Fix a regression in panic output.
Update test-case to exercise more of the panic formatter.
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 20d12bc..dcb3cb1 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -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));
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 94b2aee..ff9a65b 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -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");
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 15b2d9a..e8a1ac1 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -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);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc
index 46d778c..2e9a385 100644
--- a/bin/varnishtest/tests/v00010.vtc
+++ b/bin/varnishtest/tests/v00010.vtc
@@ -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);
}
}
@@ -49,5 +62,22 @@ 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
expect resp.http.foo == "foo"
} -run
More information about the varnish-commit
mailing list