[master] e258ca1 Remove negative Age assertion and truncate to zero instead.

Martin Blix Grydeland martin at varnish-software.com
Fri Apr 25 15:50:41 CEST 2014


commit e258ca15604b210aad3d70960eccd21fce645778
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Apr 24 14:55:06 2014 +0200

    Remove negative Age assertion and truncate to zero instead.
    
    The Age reported on response objects is calculated from the last
    request timestamp taken. For a cache hit that hasn't been on a
    waitinglist, that will be the Start timestamp. This opens a race where
    the requests' last timestamp could be before the objects t_origin.
    
    Truncate the Age to zero rather than assert in that case.
    
    Fixes: #1486

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 2518422..88cebcd 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -117,10 +117,12 @@ cnt_deliver(struct worker *wrk, struct req *req)
 	/* We base Age calculation upon the last timestamp taken during
 	   client request processing. This gives some inaccuracy, but
 	   since Age is only full second resolution that shouldn't
-	   matter. */
-	assert(req->t_prev > req->obj->exp.t_origin);
+	   matter. (Last request timestamp could be a Start timestamp
+	   taken before the object entered into cache leading to negative
+	   age. Truncate to zero in that case).
+	*/
 	http_PrintfHeader(req->resp, "Age: %.0f",
-	    req->t_prev - req->obj->exp.t_origin);
+	    fmax(0., req->t_prev - req->obj->exp.t_origin));
 
 	http_SetHeader(req->resp, "Via: 1.1 varnish (v4)");
 



More information about the varnish-commit mailing list