[master] eaa6454 When obj.ttl or beresp.ttl is set to zero, also set the corresponding grace to zero.

Poul-Henning Kamp phk at varnish-cache.org
Fri Jan 28 23:58:44 CET 2011


commit eaa6454e006f5844834cc2c02ef3ca7de1a87a42
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 28 22:57:45 2011 +0000

    When obj.ttl or beresp.ttl is set to zero, also set the corresponding
    grace to zero.
    
    if you want ttl=0 with a non-zero grace, set ttl first, then set grace.

diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c
index cc0d11e..9fa56ba 100644
--- a/bin/varnishd/cache_vrt_var.c
+++ b/bin/varnishd/cache_vrt_var.c
@@ -246,9 +246,10 @@ VRT_l_beresp_ttl(const struct sess *sp, double a)
 	 * of the rounding to seconds.
 	 * We special case and make sure that rounding does not surprise.
 	 */
-	if (a <= 0)
+	if (a <= 0) {
 		sp->wrk->ttl = sp->t_req - 1;
-	else
+		sp->wrk->grace = 0.;
+	} else
 		sp->wrk->ttl = sp->t_req + a;
 }
 
@@ -349,9 +350,10 @@ VRT_l_obj_ttl(const struct sess *sp, double a)
 	 * of the rounding to seconds.
 	 * We special case and make sure that rounding does not surprise.
 	 */
-	if (a <= 0)
+	if (a <= 0) {
 		sp->obj->ttl = sp->t_req - 1;
-	else
+		sp->obj->grace = 0;
+	} else
 		sp->obj->ttl = sp->t_req + a;
 	EXP_Rearm(sp->obj);
 }



More information about the varnish-commit mailing list