[4.0] e388600 Make a dedicated cleanup function for req->vary_? to match the dedicated setup function we have.

Lasse Karstensen lkarsten at varnish-software.com
Tue Sep 23 15:09:29 CEST 2014


commit e38860038b92e4e2e0b27882fd9af5ab487665a3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 29 19:09:09 2014 +0000

    Make a dedicated cleanup function for req->vary_? to match the
    dedicated setup function we have.
    
    Fixes	#1553

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 414ec87..04debc8 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1187,6 +1187,7 @@ int VRY_Create(struct busyobj *bo, struct vsb **psb);
 int VRY_Match(struct req *, const uint8_t *vary);
 unsigned VRY_Validate(const uint8_t *vary);
 void VRY_Prep(struct req *);
+void VRY_Clear(struct req *);
 enum vry_finish_flag { KEEP, DISCARD };
 void VRY_Finish(struct req *req, enum vry_finish_flag);
 
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 56762e9..073e9fb 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -472,8 +472,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
 
 	if (boc != NULL) {
 		(void)HSH_DerefObjCore(&wrk->stats, &boc);
-		free(req->vary_b);
-		req->vary_b = NULL;
+		VRY_Clear(req);
 	}
 
 	return (REQ_FSM_MORE);
@@ -527,7 +526,7 @@ cnt_miss(struct worker *wrk, struct req *req)
 	default:
 		WRONG("Illegal return from vcl_miss{}");
 	}
-	free(req->vary_b);
+	VRY_Clear(req);
 	if (o != NULL)
 		(void)HSH_DerefObj(&wrk->stats, &o);
 	AZ(HSH_DerefObjCore(&wrk->stats, &req->objcore));
diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 4baa65a..e4a7628 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -238,6 +238,18 @@ VRY_Prep(struct req *req)
 		req->vary_b[2] = '\0';
 }
 
+void
+VRY_Clear(struct req *req)
+{
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	if (req->vary_b != NULL)
+		free(req->vary_b);
+	req->vary_b = NULL;
+	AZ(req->vary_e);
+	AZ(req->vary_l);
+}
+
 /**********************************************************************
  * Finish predictive vary processing
  */



More information about the varnish-commit mailing list