]> err.no Git - varnish/commitdiff
Implement "now" and "obj.lastuse", with a note to the effect that the use
authordes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 14:19:40 +0000 (14:19 +0000)
committerdes <des@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 3 Jul 2007 14:19:40 +0000 (14:19 +0000)
of timestamps and clock_gettime() throughout Varnish needs reviewing (as
per IRC discussion with phk)

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1630 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_vrt.c

index 5bbdbc0603741a7117cc2c55347280e35820fa31..a7ad1a830ca693a9273a67a162f2efa0fd37b0c7 100644 (file)
@@ -304,3 +304,28 @@ VRT_l_req_hash(struct sess *sp, const char *str)
        sp->hash_e[l] = '#';
        sp->hash_e += l + 1;
 }
+
+/*--------------------------------------------------------------------*/
+
+double
+VRT_r_now(struct sess *sp)
+{
+       struct timespec now;
+
+       (void)sp;
+       /* XXX use of clock_gettime() needs review */
+       clock_gettime(CLOCK_MONOTONIC, &now);
+       return (now.tv_sec);
+}
+
+double
+VRT_r_obj_lastuse(struct sess *sp)
+{
+       struct timespec now;
+
+       CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+       CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);       /* XXX */
+       /* XXX use of clock_gettime() needs review */
+       clock_gettime(CLOCK_MONOTONIC, &now);
+       return (now.tv_sec - sp->obj->lru_stamp);
+}