From: des Date: Tue, 3 Jul 2007 14:19:40 +0000 (+0000) Subject: Implement "now" and "obj.lastuse", with a note to the effect that the use X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd6e808ee8e303bbbf5907393caeafbd1114e986;p=varnish 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) git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1630 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 5bbdbc06..a7ad1a83 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -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); +}