[master] e223671 Handle NULL pointer structs with pan_already()

Poul-Henning Kamp phk at FreeBSD.org
Sat Feb 18 10:09:05 CET 2017


commit e22367142f00e222b237b63f7a2d97870d747c5b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sat Feb 18 09:04:43 2017 +0000

    Handle NULL pointer structs with pan_already()
    
    Say so if feature +short_panic supresses output.

diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 11390b6..bc21304 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -127,6 +127,10 @@ pan_already(struct vsb *vsb, const void *ptr)
 {
 	int i;
 
+	if (ptr == NULL) {
+		VSB_printf(vsb, "},\n");
+		return (1);
+	}
 	for (i = 0; i < already_idx; i++) {
 		if (already_list[i] == ptr) {
 			VSB_printf(vsb, "  [Already dumped, see above]\n");
@@ -635,15 +639,18 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 
 	if (!FEATURE(FEATURE_SHORT_PANIC)) {
 		req = THR_GetRequest();
-		if (req != NULL) {
-			pan_req(pan_vsb, req);
+		VSB_cat(pan_vsb, "thr.");
+		pan_req(pan_vsb, req);
+		if (req != NULL)
 			VSL_Flush(req->vsl, 0);
-		}
 		bo = THR_GetBusyobj();
-		if (bo != NULL) {
-			pan_busyobj(pan_vsb, bo);
+		VSB_cat(pan_vsb, "thr.");
+		pan_busyobj(pan_vsb, bo);
+		if (bo != NULL)
 			VSL_Flush(bo->vsl, 0);
-		}
+	} else {
+		VSB_printf(pan_vsb,
+		    "Feature short panic supressed details.\n");
 	}
 	VSB_printf(pan_vsb, "\n");
 	VSB_putc(pan_vsb, '\0');	/* NUL termination */
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 966658b..00fda7c 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -400,7 +400,9 @@ h2_do_req(struct worker *wrk, void *priv)
 
 	CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
 	CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
+	THR_SetRequest(req);
 	assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK);
+	THR_SetRequest(NULL);
 	VSL(SLT_Debug, 0, "H2REQ CNT done");
 	/* XXX clean up req */
 	r2->state = H2_S_CLOSED;
@@ -772,7 +774,6 @@ h2_new_session(struct worker *wrk, void *arg)
 
 	assert(req->transport == &H2_transport);
 
-	THR_SetRequest(req);
 	wsp = WS_Snapshot(wrk->aws);
 
 	switch(req->err_code) {



More information about the varnish-commit mailing list