From: phk Date: Thu, 12 Jul 2007 09:49:26 +0000 (+0000) Subject: Change all timekeeping to use doubles instead of time_t and struct timespec. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6d64cdbd97d6b92738738ab2fe49559cfbbd56f;p=varnish Change all timekeeping to use doubles instead of time_t and struct timespec. Eliminate all direct calls to time(2) and clockgettime(2) and use TIM_real() and TIM_mono() exclusively. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1671 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 641eba99..e58fe494 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -131,7 +131,7 @@ struct http { /*--------------------------------------------------------------------*/ struct acct { - time_t first; + double first; uint64_t sess; uint64_t req; uint64_t pipe; @@ -149,7 +149,7 @@ struct worker { struct objhead *nobjhead; struct object *nobj; - time_t idle; + double idle; int pipe[2]; @@ -247,11 +247,11 @@ struct object { unsigned busy; unsigned len; - time_t age; - time_t entered; - time_t ttl; + double age; + double entered; + double ttl; - time_t last_modified; + double last_modified; struct http http; TAILQ_ENTRY(object) list; @@ -262,7 +262,7 @@ struct object { TAILQ_HEAD(, sess) waitinglist; - time_t lru_stamp; + double lru_stamp; TAILQ_ENTRY(object) lru; }; @@ -300,10 +300,10 @@ struct sess { const char *doclose; struct http *http; - struct timespec t_open; - struct timespec t_req; - struct timespec t_resp; - struct timespec t_end; + double t_open; + double t_req; + double t_resp; + double t_end; enum step step; unsigned handling; @@ -492,11 +492,11 @@ void VCL_Get(struct VCL_conf **vcc); /* cache_lru.c */ // void LRU_Init(void); -void LRU_Enter(struct object *o, time_t stamp); +void LRU_Enter(struct object *o, double stamp); void LRU_Remove(struct object *o); int LRU_DiscardOne(void); int LRU_DiscardSpace(int64_t quota); -int LRU_DiscardTime(time_t cutoff); +int LRU_DiscardTime(double cutoff); #define VCL_RET_MAC(l,u,b,n) #define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct sess *); diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index b505eb8f..26bb6696 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -44,10 +44,6 @@ #include #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #ifndef HAVE_SRANDOMDEV #include "compat/srandomdev.h" #endif @@ -116,7 +112,7 @@ VCA_Prep(struct sess *sp) TCP_name(sp->sockaddr, sp->sockaddrlen, sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port); - sp->acct.first = sp->t_open.tv_sec; + sp->acct.first = sp->t_open; if (need_test) sock_test(sp->fd); if (need_linger) @@ -195,7 +191,7 @@ vca_acct(void *arg) sp->fd = i; sp->id = i; - (void)clock_gettime(CLOCK_REALTIME, &sp->t_open); + sp->t_open = TIM_real(); http_RecvPrep(sp->http); sp->step = STP_FIRST; diff --git a/varnish-cache/bin/varnishd/cache_acceptor_epoll.c b/varnish-cache/bin/varnishd/cache_acceptor_epoll.c index 8db88478..5c6f6e5d 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_epoll.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_epoll.c @@ -41,10 +41,6 @@ #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "heritage.h" #include "shmlog.h" #include "cache.h" @@ -74,7 +70,7 @@ static void * vca_main(void *arg) { struct epoll_event ev; - struct timespec ts; + double deadline; struct sess *sp, *sp2; int i; @@ -108,14 +104,10 @@ vca_main(void *arg) } } /* check for timeouts */ - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec -= params->sess_timeout; + deadline = TIM_real() - params->sess_timeout TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - if (sp->t_open.tv_sec > ts.tv_sec) - continue; - if (sp->t_open.tv_sec == ts.tv_sec && - sp->t_open.tv_nsec > ts.tv_nsec) + if (sp->t_open > deadline) continue; TAILQ_REMOVE(&sesshead, sp, list); vca_del(sp->fd); diff --git a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c index c5a70da6..5da41ff2 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c @@ -43,10 +43,6 @@ #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "heritage.h" #include "shmlog.h" #include "cache.h" @@ -129,7 +125,7 @@ vca_kqueue_main(void *arg) { struct kevent ke[NKEV], *kp; int j, n, dotimer; - struct timespec ts; + double deadline; struct sess *sp; (void)arg; @@ -160,16 +156,12 @@ vca_kqueue_main(void *arg) } if (!dotimer) continue; - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec -= params->sess_timeout; + deadline = TIM_real() - params->sess_timeout; for (;;) { sp = TAILQ_FIRST(&sesshead); if (sp == NULL) break; - if (sp->t_open.tv_sec > ts.tv_sec) - break; - if (sp->t_open.tv_sec == ts.tv_sec && - sp->t_open.tv_nsec > ts.tv_nsec) + if (sp->t_open > deadline) break; TAILQ_REMOVE(&sesshead, sp, list); vca_close_session(sp, "timeout"); diff --git a/varnish-cache/bin/varnishd/cache_acceptor_poll.c b/varnish-cache/bin/varnishd/cache_acceptor_poll.c index 7a2fffdf..03f8004b 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_poll.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_poll.c @@ -42,10 +42,6 @@ #include #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "heritage.h" #include "shmlog.h" #include "cache.h" @@ -108,7 +104,7 @@ vca_main(void *arg) { unsigned v; struct sess *sp, *sp2; - struct timespec ts; + double deadline; int i, fd; (void)arg; @@ -125,8 +121,7 @@ vca_main(void *arg) TAILQ_INSERT_TAIL(&sesshead, sp, list); vca_poll(sp->fd); } - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec -= params->sess_timeout; + deadline = TIM_real() - params->sess_timeout; TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) { if (v == 0) break; @@ -145,10 +140,7 @@ vca_main(void *arg) SES_Delete(sp); continue; } - if (sp->t_open.tv_sec > ts.tv_sec) - continue; - if (sp->t_open.tv_sec == ts.tv_sec && - sp->t_open.tv_nsec > ts.tv_nsec) + if (sp->t_open > deadline) continue; TAILQ_REMOVE(&sesshead, sp, list); vca_unpoll(fd); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index d4f1005b..62ce3914 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -62,10 +62,6 @@ DOT start -> recv [style=bold,color=green,weight=4] #include #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #ifndef HAVE_SRANDOMDEV #include "compat/srandomdev.h" #endif @@ -172,16 +168,6 @@ DOT label="Request completed" DOT ] */ -static double -cnt_dt(struct timespec *t1, struct timespec *t2) -{ - double dt; - - dt = (t2->tv_sec - t1->tv_sec); - dt += (t2->tv_nsec - t1->tv_nsec) * 1e-9; - return (dt); -} - static int cnt_done(struct sess *sp) { @@ -197,20 +183,17 @@ cnt_done(struct sess *sp) sp->vcl = NULL; } - clock_gettime(CLOCK_REALTIME, &sp->t_end); - sp->wrk->idle = sp->t_end.tv_sec; + sp->t_end = TIM_real(); + sp->wrk->idle = sp->t_end; if (sp->xid == 0) { sp->t_req = sp->t_end; sp->t_resp = sp->t_end; } - dp = cnt_dt(&sp->t_req, &sp->t_resp); - da = cnt_dt(&sp->t_resp, &sp->t_end); - dh = cnt_dt(&sp->t_open, &sp->t_req); - WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %ld.%09ld %ld.%09ld %.9f %.9f %.9f", - sp->xid, - (long)sp->t_req.tv_sec, (long)sp->t_req.tv_nsec, - (long)sp->t_end.tv_sec, (long)sp->t_end.tv_nsec, - dh, dp, da); + dp = sp->t_resp - sp->t_req; + da = sp->t_end - sp->t_resp; + dh = sp->t_req - sp->t_open; + WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %.9f %.9f %.9f %.9f %.9f", + sp->xid, sp->t_req, sp->t_end, dh, dp, da); sp->xid = 0; sp->t_open = sp->t_end; @@ -345,7 +328,7 @@ cnt_first(struct sess *sp) assert(sp->xid == 0); VCA_Prep(sp); - sp->wrk->idle = sp->t_open.tv_sec; + sp->wrk->idle = sp->t_open; sp->wrk->acct.sess++; SES_RefSrcAddr(sp); do @@ -672,8 +655,8 @@ cnt_recv(struct sess *sp) /* Update stats of various sorts */ VSL_stats->client_req++; /* XXX not locked */ - clock_gettime(CLOCK_REALTIME, &sp->t_req); - sp->wrk->idle = sp->t_req.tv_sec; + sp->t_req = TIM_real(); + sp->wrk->idle = sp->t_req; sp->wrk->acct.req++; /* Assign XID and log */ diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index 5b090d91..1a08d4ab 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -103,11 +103,11 @@ static void * exp_hangman(void *arg) { struct object *o; - time_t t; + double t; (void)arg; - t = time(NULL); + t = TIM_real(); while (1) { LOCK(&exp_mtx); TAILQ_FOREACH(o, &exp_deathrow, deathrow) { @@ -153,7 +153,7 @@ exp_prefetch(void *arg) { struct worker ww; struct object *o; - time_t t; + double t; struct sess *sp; struct object *o2; @@ -168,7 +168,7 @@ exp_prefetch(void *arg) sleep(10); /* Takes time for VCL to arrive */ VCL_Get(&sp->vcl); - t = time(NULL); + t = TIM_real(); while (1) { LOCK(&exp_mtx); o = binheap_root(exp_heap); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index aa4e715f..b41df8a1 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -152,7 +152,7 @@ VSLR(SLT_Debug, sp->fd, sp->hash_b, sp->hash_e); /* ignore */ } else if (o->ttl == 0) { /* Object banned but not reaped yet */ - } else if (o->ttl <= sp->t_req.tv_sec) { + } else if (o->ttl <= sp->t_req) { /* Object expired */ } else if (BAN_CheckObject(o, h->hd[HTTP_HDR_URL].b)) { o->ttl = 0; @@ -166,7 +166,7 @@ VSLR(SLT_Debug, sp->fd, sp->hash_b, sp->hash_e); if (o != NULL) { UNLOCK(&oh->mtx); (void)hash->deref(oh); - LRU_Enter(o, sp->t_req.tv_sec); + LRU_Enter(o, sp->t_req); return (o); } @@ -178,7 +178,7 @@ VSLR(SLT_Debug, sp->fd, sp->hash_b, sp->hash_e); /* NB: do not deref objhead the new object inherits our reference */ UNLOCK(&oh->mtx); BAN_NewObj(o); - LRU_Enter(o, sp->t_req.tv_sec); + LRU_Enter(o, sp->t_req); return (o); } diff --git a/varnish-cache/bin/varnishd/cache_lru.c b/varnish-cache/bin/varnishd/cache_lru.c index 9a86183b..58459120 100644 --- a/varnish-cache/bin/varnishd/cache_lru.c +++ b/varnish-cache/bin/varnishd/cache_lru.c @@ -71,7 +71,7 @@ LRU_Init(void) * if it's already in it and hasn't moved in a while. */ void -LRU_Enter(struct object *o, time_t stamp) +LRU_Enter(struct object *o, double stamp) { CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -199,7 +199,7 @@ LRU_DiscardSpace(int64_t quota) * number of objects that were discarded. */ int -LRU_DiscardTime(time_t cutoff) +LRU_DiscardTime(double cutoff) { struct object *first = TAILQ_FIRST(&lru_list); struct object *o; diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 195ec0fc..2ac2450f 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -38,10 +38,6 @@ #include #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "shmlog.h" #include "heritage.h" #include "cache.h" @@ -106,7 +102,7 @@ PipeSession(struct sess *sp) vbe_free_bereq(bereq); bereq = NULL; - clock_gettime(CLOCK_REALTIME, &sp->t_resp); + sp->t_resp = TIM_real(); memset(fds, 0, sizeof fds); fds[0].fd = vc->fd; diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 74c47e27..91b70540 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -381,7 +381,7 @@ wrk_addpools(unsigned t) static void * wrk_reaperthread(void *priv) { - time_t now; + double now; struct worker *w; struct wq *qp; unsigned u; @@ -392,7 +392,7 @@ wrk_reaperthread(void *priv) sleep(1); if (VSL_stats->n_wrk <= params->wthread_min) continue; - now = time(NULL); + now = TIM_real(); for (u = 0; u < nwq; u++) { qp = wq[u]; LOCK(&qp->mtx); diff --git a/varnish-cache/bin/varnishd/cache_response.c b/varnish-cache/bin/varnishd/cache_response.c index 8669e43e..b2b7c8f8 100644 --- a/varnish-cache/bin/varnishd/cache_response.c +++ b/varnish-cache/bin/varnishd/cache_response.c @@ -32,10 +32,6 @@ #include #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "shmlog.h" #include "heritage.h" #include "cache.h" @@ -75,7 +71,7 @@ res_do_304(struct sess *sp) sp->http->logtag = HTTP_Tx; http_SetResp(sp->http, "HTTP/1.1", "304", "Not Modified"); - TIM_format(sp->t_req.tv_sec, lm); + TIM_format(sp->t_req, lm); http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Date: %s", lm); http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish"); http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u", sp->xid); @@ -95,12 +91,12 @@ static int res_do_conds(struct sess *sp) { char *p; - time_t ims; + double ims; if (sp->obj->last_modified > 0 && http_GetHdr(sp->http, H_If_Modified_Since, &p)) { ims = TIM_parse(p); - if (ims > sp->t_req.tv_sec) /* [RFC2616 14.25] */ + if (ims > sp->t_req) /* [RFC2616 14.25] */ return (0); if (sp->obj->last_modified > ims) { return (0); @@ -134,8 +130,8 @@ RES_BuildHttp(struct sess *sp) else http_PrintfHeader(sp->wrk, sp->fd, sp->http, "X-Varnish: %u", sp->xid); - http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Age: %u", - sp->obj->age + sp->t_resp.tv_sec - sp->obj->entered); + http_PrintfHeader(sp->wrk, sp->fd, sp->http, "Age: %.0f", + sp->obj->age + sp->t_resp - sp->obj->entered); http_SetHeader(sp->wrk, sp->fd, sp->http, "Via: 1.1 varnish"); if (sp->doclose != NULL) http_SetHeader(sp->wrk, sp->fd, sp->http, "Connection: close"); @@ -151,7 +147,7 @@ RES_WriteObj(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - clock_gettime(CLOCK_REALTIME, &sp->t_resp); + sp->t_resp = TIM_real(); WRK_Reset(sp->wrk, &sp->fd); sp->wrk->acct.hdrbytes += http_Write(sp->wrk, sp->http, 1); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); diff --git a/varnish-cache/bin/varnishd/cache_session.c b/varnish-cache/bin/varnishd/cache_session.c index a2c3799c..6f601525 100644 --- a/varnish-cache/bin/varnishd/cache_session.c +++ b/varnish-cache/bin/varnishd/cache_session.c @@ -91,7 +91,7 @@ struct srcaddr { char addr[TCP_ADDRBUFSIZE]; unsigned nref; - time_t ttl; + double ttl; struct acct acct; }; @@ -120,7 +120,7 @@ SES_RefSrcAddr(struct sess *sp) unsigned u, v; struct srcaddr *c, *c2, *c3; struct srcaddrhead *ch; - time_t now; + double now; if (params->srcaddr_ttl == 0) { sp->srcaddr = NULL; @@ -131,7 +131,7 @@ SES_RefSrcAddr(struct sess *sp) v = u % nsrchash; ch = &srchash[v]; CHECK_OBJ(ch, SRCADDRHEAD_MAGIC); - now = sp->t_open.tv_sec; + now = sp->t_open; if (sp->wrk->srcaddr == NULL) { sp->wrk->srcaddr = calloc(sizeof *sp->wrk->srcaddr, 1); XXXAN(sp->wrk->srcaddr); @@ -233,8 +233,8 @@ SES_Charge(struct sess *sp) b = sp->srcaddr->acct; UNLOCK(&sp->srcaddr->sah->mtx); WSL(sp->wrk, SLT_StatAddr, 0, - "%s 0 %d %ju %ju %ju %ju %ju %ju %ju", - sp->srcaddr->addr, sp->t_end.tv_sec - b.first, + "%s 0 %.0f %ju %ju %ju %ju %ju %ju %ju", + sp->srcaddr->addr, sp->t_end - b.first, b.sess, b.req, b.pipe, b.pass, b.fetch, b.hdrbytes, b.bodybytes); } @@ -333,8 +333,8 @@ SES_Delete(struct sess *sp) AZ(sp->vcl); VSL_stats->n_sess--; ses_relsrcaddr(sp); - VSL(SLT_StatSess, sp->id, "%s %s %d %ju %ju %ju %ju %ju %ju %ju", - sp->addr, sp->port, sp->t_end.tv_sec - b->first, + VSL(SLT_StatSess, sp->id, "%s %s %.0f %ju %ju %ju %ju %ju %ju %ju", + sp->addr, sp->port, sp->t_end - b->first, b->sess, b->req, b->pipe, b->pass, b->fetch, b->hdrbytes, b->bodybytes); if (sm->workspace != params->mem_workspace) { diff --git a/varnish-cache/bin/varnishd/cache_synthetic.c b/varnish-cache/bin/varnishd/cache_synthetic.c index 64f19d15..28ded215 100644 --- a/varnish-cache/bin/varnishd/cache_synthetic.c +++ b/varnish-cache/bin/varnishd/cache_synthetic.c @@ -33,10 +33,6 @@ #include -#ifndef HAVE_CLOCK_GETTIME -#include "compat/clock_gettime.h" -#endif - #include "shmlog.h" #include "heritage.h" #include "cache.h" @@ -56,7 +52,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl) struct vsb vsb; const char *msg; char date[40]; - time_t now; + double now; int fd; assert(status >= 100 && status <= 999); @@ -71,7 +67,7 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl) fd = sp->fd; o = sp->obj; h = &o->http; - time(&now); + now = TIM_real(); /* look up HTTP response */ msg = http_StatusMessage(status); diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 88a1a013..612a7d5c 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -324,11 +324,11 @@ VRT_l_obj_ttl(struct sess *sp, double a) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ - WSL(sp->wrk, SLT_TTL, sp->fd, "%u VCL %.0f %u", - sp->obj->xid, a, sp->t_req.tv_sec); + WSL(sp->wrk, SLT_TTL, sp->fd, "%u VCL %.0f %.0f", + sp->obj->xid, a, sp->t_req); if (a < 0) a = 0; - sp->obj->ttl = sp->t_req.tv_sec + (int)a; + sp->obj->ttl = sp->t_req + a; if (sp->obj->heap_idx != 0) EXP_TTLchange(sp->obj); } @@ -338,7 +338,7 @@ VRT_r_obj_ttl(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ - return (sp->obj->ttl - sp->t_req.tv_sec); + return (sp->obj->ttl - sp->t_req); } /*--------------------------------------------------------------------*/ @@ -460,24 +460,18 @@ VRT_l_req_hash(struct sess *sp, const char *str) 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); + return (TIM_mono()); } 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); + return (TIM_mono() - sp->obj->lru_stamp); } /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/rfc2616.c b/varnish-cache/bin/varnishd/rfc2616.c index 16b52548..8397dc3e 100644 --- a/varnish-cache/bin/varnishd/rfc2616.c +++ b/varnish-cache/bin/varnishd/rfc2616.c @@ -98,12 +98,12 @@ ttd = min(ttd, our_clock + hard_upper_ttl) #endif -static time_t +static double RFC2616_Ttl(struct sess *sp, struct http *hp, struct object *obj) { int retirement_age; unsigned u1, u2; - time_t h_date, h_expires, ttd; + double h_date, h_expires, ttd; char *p; retirement_age = INT_MAX;