Mailing List Archive

r1630 - trunk/varnish-cache/bin/varnishd
Author: des
Date: 2007-07-03 16:19:40 +0200 (Tue, 03 Jul 2007)
New Revision: 1630

Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Implement "now" and "obj.lastuse", with a note to the effect that the use
of timestamps and clock_gettime() throughout Varnish needs reviewing (as
per IRC discussion with phk)


Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-03 14:18:24 UTC (rev 1629)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-03 14:19:40 UTC (rev 1630)
@@ -304,3 +304,28 @@
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);
+}