]> err.no Git - varnish/commitdiff
Change all timekeeping to use doubles instead of time_t and struct timespec.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 12 Jul 2007 09:49:26 +0000 (09:49 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 12 Jul 2007 09:49:26 +0000 (09:49 +0000)
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

16 files changed:
varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_acceptor.c
varnish-cache/bin/varnishd/cache_acceptor_epoll.c
varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
varnish-cache/bin/varnishd/cache_acceptor_poll.c
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_expire.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_lru.c
varnish-cache/bin/varnishd/cache_pipe.c
varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/cache_response.c
varnish-cache/bin/varnishd/cache_session.c
varnish-cache/bin/varnishd/cache_synthetic.c
varnish-cache/bin/varnishd/cache_vrt.c
varnish-cache/bin/varnishd/rfc2616.c

index 641eba99aaaeb3d6d401c497b9c8f32abffb9064..e58fe494db6c2d521a794297ecab6a45153453c8 100644 (file)
@@ -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 *);
index b505eb8f17d1654e9534440d2ccc7ceccfae05de..26bb66961322de66501bb5afc4b444d3e4536ff1 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#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;
index 8db884788c20f84a142218ce9cbe217ace82ebf7..5c6f6e5d6c66f251d1e8f9acb3d79bfd7dfe0e4c 100644 (file)
 
 #include <sys/epoll.h>
 
-#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);
index c5a70da6c676302fb40979fba3e23824e3b26c30..5da41ff2fd846eeaa62f881074dc290c22c8680b 100644 (file)
 
 #include <sys/event.h>
 
-#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");
index 7a2fffdf11290054db7dcf13a57147957a25cc46..03f8004b3bf7fc63d168c1e7c89ce6efdae5260e 100644 (file)
 #include <unistd.h>
 #include <poll.h>
 
-#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);
index d4f1005b70df344c223996c7ad25c7647507a092..62ce3914828619a90268864c98792911cf44dcb4 100644 (file)
@@ -62,10 +62,6 @@ DOT start -> recv [style=bold,color=green,weight=4]
 #include <string.h>
 #include <unistd.h>
 
-#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 */
index 5b090d9102c73243c69f97b88199f3410365db76..1a08d4ab4d95bfd4acb1440ecac5e7365ef75533 100644 (file)
@@ -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);
index aa4e715f2f764618e49dab9077d45bef255243b4..b41df8a1b7de089876aa944513cac28ac536e9b8 100644 (file)
@@ -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);
 }
 
index 9a86183bb0d7bcb49ba1ad9648473cf96386e1c6..58459120d35f3e42b4e865d5d78064785838beb8 100644 (file)
@@ -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;
index 195ec0fc39caba3b1ef7359f9cec4e7e39540bcc..2ac2450fa766ed38760727467cdabab78465674b 100644 (file)
 #include <stdlib.h>
 #include <sys/socket.h>
 
-#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;
index 74c47e27fa1e032e6f1b3499de12b9d803871729..91b7054072e74806efd30e3b6d11e95be51fc6b2 100644 (file)
@@ -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);
index 8669e43e3b4cb3b79a0cdb524a962d34b06aa2d6..b2b7c8f8e1d92c9fcc54f99a93fd8732efe423a5 100644 (file)
 #include <sys/types.h>
 #include <sys/time.h>
 
-#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);
index a2c3799ca08c2832be5c0c552a9c9cbc3b3f17e5..6f60152533d4ea00a9ad958953a7e452eec1929b 100644 (file)
@@ -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) {
index 64f19d155f1d7250840841f37b27079294aa9326..28ded2151254ccaae7e36d07bb7389a8d0ee1ca4 100644 (file)
 
 #include <stdlib.h>
 
-#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);
index 88a1a0136ce801108df1a777dbdcdfb7129c4207..612a7d5c3757167ee3766b2a6b72172cfc87d442 100644 (file)
@@ -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);
 }
 
 /*--------------------------------------------------------------------*/
index 16b52548aca226b7c8dc9960758d5f15f2c7e002..8397dc3eacb52999d896949f5cb7d8a6a98998f6 100644 (file)
        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;