r1671 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Jul 12 11:49:26 CEST 2007


Author: phk
Date: 2007-07-12 11:49:26 +0200 (Thu, 12 Jul 2007)
New Revision: 1671

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_acceptor.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
   trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/cache_lru.c
   trunk/varnish-cache/bin/varnishd/cache_pipe.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/cache_response.c
   trunk/varnish-cache/bin/varnishd/cache_session.c
   trunk/varnish-cache/bin/varnishd/cache_synthetic.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/bin/varnishd/rfc2616.c
Log:
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.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-07-12 09:49:26 UTC (rev 1671)
@@ -131,7 +131,7 @@
 /*--------------------------------------------------------------------*/
 
 struct acct {
-	time_t			first;
+	double			first;
 	uint64_t		sess;
 	uint64_t		req;
 	uint64_t		pipe;
@@ -149,7 +149,7 @@
 	struct objhead		*nobjhead;
 	struct object		*nobj;
 
-	time_t			idle;
+	double			idle;
 
 	int			pipe[2];
 
@@ -247,11 +247,11 @@
 	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 @@
 
 	TAILQ_HEAD(, sess)	waitinglist;
 
-	time_t			lru_stamp;
+	double			lru_stamp;
 	TAILQ_ENTRY(object)	lru;
 };
 
@@ -300,10 +300,10 @@
 	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 @@
 
 /* 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 *);

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -44,10 +44,6 @@
 #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 @@
 	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 @@
 
 			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;

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -41,10 +41,6 @@
 
 #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 @@
 vca_main(void *arg)
 {
 	struct epoll_event ev;
-	struct timespec ts;
+	double deadline;
 	struct sess *sp, *sp2;
 	int i;
 
@@ -108,15 +104,11 @@
 			}
 		}
 		/* 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)
+			if (sp->t_open > deadline)
 				continue;
-			if (sp->t_open.tv_sec == ts.tv_sec &&
-			    sp->t_open.tv_nsec > ts.tv_nsec)
-				continue;
 			TAILQ_REMOVE(&sesshead, sp, list);
 			vca_del(sp->fd);
 			vca_close_session(sp, "timeout");

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -43,10 +43,6 @@
 
 #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 @@
 {
 	struct kevent ke[NKEV], *kp;
 	int j, n, dotimer;
-	struct timespec ts;
+	double deadline;
 	struct sess *sp;
 
 	(void)arg;
@@ -160,17 +156,13 @@
 		}
 		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)
+			if (sp->t_open > deadline)
 				break;
-			if (sp->t_open.tv_sec == ts.tv_sec &&
-			    sp->t_open.tv_nsec > ts.tv_nsec)
-				break;
 			TAILQ_REMOVE(&sesshead, sp, list);
 			vca_close_session(sp, "timeout");
 			SES_Delete(sp);

Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor_poll.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -42,10 +42,6 @@
 #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 @@
 {
 	unsigned v;
 	struct sess *sp, *sp2;
-	struct timespec ts;
+	double deadline;
 	int i, fd;
 
 	(void)arg;
@@ -125,8 +121,7 @@
 			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,11 +140,8 @@
 					SES_Delete(sp);
 				continue;
 			}
-			if (sp->t_open.tv_sec > ts.tv_sec)
+			if (sp->t_open > deadline)
 				continue;
-			if (sp->t_open.tv_sec == ts.tv_sec &&
-			    sp->t_open.tv_nsec > ts.tv_nsec)
-				continue;
 			TAILQ_REMOVE(&sesshead, sp, list);
 			vca_unpoll(fd);
 			vca_close_session(sp, "timeout");

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -62,10 +62,6 @@
 #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	]
  */
 
-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 @@
 		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 @@
 
 	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 @@
 
 	/* 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 */

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -103,11 +103,11 @@
 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 @@
 {
 	struct worker ww;
 	struct object *o;
-	time_t t;
+	double t;
 	struct sess *sp;
 	struct object *o2;
 
@@ -168,7 +168,7 @@
 
 	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);

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -152,7 +152,7 @@
 			/* 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 @@
 	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 @@
 	/* 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);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/cache_lru.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_lru.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_lru.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -71,7 +71,7 @@
  * 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 @@
  * 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;

Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -38,10 +38,6 @@
 #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 @@
 	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;

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -381,7 +381,7 @@
 static void *
 wrk_reaperthread(void *priv)
 {
-	time_t	now;
+	double	now;
 	struct worker *w;
 	struct wq *qp;
 	unsigned u;
@@ -392,7 +392,7 @@
 		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);

Modified: trunk/varnish-cache/bin/varnishd/cache_response.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_response.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_response.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -32,10 +32,6 @@
 #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 @@
 	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 @@
 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 @@
 	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 @@
 
 	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);

Modified: trunk/varnish-cache/bin/varnishd/cache_session.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_session.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_session.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -91,7 +91,7 @@
 	char			addr[TCP_ADDRBUFSIZE];
 	unsigned		nref;
 
-	time_t			ttl;
+	double			ttl;
 
 	struct acct		acct;
 };
@@ -120,7 +120,7 @@
 	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 @@
 	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 @@
 		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 @@
 	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) {

Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_synthetic.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -33,10 +33,6 @@
 
 #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 @@
 	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 @@
 	fd = sp->fd;
 	o = sp->obj;
 	h = &o->http;
-	time(&now);
+	now = TIM_real();
 
 	/* look up HTTP response */
 	msg = http_StatusMessage(status);

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -324,11 +324,11 @@
 
 	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 @@
 {
 	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 @@
 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);
 }
 
 /*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/rfc2616.c	2007-07-12 09:25:45 UTC (rev 1670)
+++ trunk/varnish-cache/bin/varnishd/rfc2616.c	2007-07-12 09:49:26 UTC (rev 1671)
@@ -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;




More information about the varnish-commit mailing list