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

Poul-Henning Kamp phk at FreeBSD.org
Tue Jul 29 21:09:46 CEST 2014


commit a309f194b7c0cb74652da9f01fbde513c807ce33
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 37bc660..ceaf2e6 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1143,6 +1143,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 e630160..9cb5c34 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -469,8 +469,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);
@@ -524,7 +523,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