[master] 79687f134 more double->vtim_*

Nils Goroll nils.goroll at uplex.de
Thu Oct 18 17:08:10 UTC 2018


commit 79687f1344387a26d5e3b0a3b0454ac917db76de
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Oct 18 17:55:37 2018 +0200

    more double->vtim_*
    
    Reviews appreciated.
    
    I will most likely continue applying these changes in smaller chunks
    because a) this kind of work is boring and b) in the hope that smaller
    chunks will get reviewed better.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3a3453c60..a829a43d7 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -342,10 +342,10 @@ struct objcore {
 	struct storeobj		stobj[1];
 	struct objhead		*objhead;
 	struct boc		*boc;
-	double			timer_when;
+	vtim_real		timer_when;
 	long			hits;
 
-	double			t_origin;
+	vtim_real		t_origin;
 	float			ttl;
 	float			grace;
 	float			keep;
@@ -357,7 +357,7 @@ struct objcore {
 	uint16_t		oa_present;
 
 	unsigned		timer_idx;	// XXX 4Gobj limit
-	double			last_lru;
+	vtim_real		last_lru;
 	VTAILQ_ENTRY(objcore)	hsh_list;
 	VTAILQ_ENTRY(objcore)	lru_list;
 	VTAILQ_ENTRY(objcore)	ban_list;
@@ -419,8 +419,8 @@ struct busyobj {
 	vtim_dur		between_bytes_timeout;
 
 	/* Timers */
-	double			t_first;	/* First timestamp logged */
-	double			t_prev;		/* Previous timestamp logged */
+	vtim_real		t_first;	/* First timestamp logged */
+	vtim_real		t_prev;		/* Previous timestamp logged */
 
 	/* Acct */
 	struct acct_bereq	acct;
@@ -478,8 +478,8 @@ struct req {
 
 	uint8_t			digest[DIGEST_LEN];
 
-	double			d_ttl;
-	double			d_grace;
+	vtim_dur		d_ttl;
+	vtim_dur		d_grace;
 
 	ssize_t			req_bodybytes;	/* Parsed req bodybytes */
 	const struct stevedore	*storage;
@@ -490,9 +490,9 @@ struct req {
 	uintptr_t		ws_req;		/* WS above request data */
 
 	/* Timestamps */
-	double			t_first;	/* First timestamp logged */
-	double			t_prev;		/* Previous timestamp logged */
-	double			t_req;		/* Headers complete */
+	vtim_real		t_first;	/* First timestamp logged */
+	vtim_real		t_prev;		/* Previous timestamp logged */
+	vtim_real		t_req;		/* Headers complete */
 
 	struct http_conn	*htc;
 	struct vfp_ctx		*vfc;
@@ -595,7 +595,7 @@ int HTTP_Decode(struct http *to, const uint8_t *fm);
 void http_ForceHeader(struct http *to, const char *hdr, const char *val);
 void http_PrintfHeader(struct http *to, const char *fmt, ...)
     v_printflike_(2, 3);
-void http_TimeHeader(struct http *to, const char *fmt, double now);
+void http_TimeHeader(struct http *to, const char *fmt, vtim_real now);
 void http_Proto(struct http *to);
 void http_SetHeader(struct http *to, const char *hdr);
 void http_SetH(struct http *to, unsigned n, const char *fm);
@@ -710,12 +710,12 @@ void VSLbv(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, va_list va);
 void VSLb(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...)
     v_printflike_(3, 4);
 void VSLbt(struct vsl_log *, enum VSL_tag_e tag, txt t);
-void VSLb_ts(struct vsl_log *, const char *event, double first, double *pprev,
-    double now);
+void VSLb_ts(struct vsl_log *, const char *event, vtim_real first,
+    vtim_real *pprev, vtim_real now);
 void VSLb_bin(struct vsl_log *, enum VSL_tag_e, ssize_t, const void*);
 
 static inline void
-VSLb_ts_req(struct req *req, const char *event, double now)
+VSLb_ts_req(struct req *req, const char *event, vtim_real now)
 {
 
 	if (isnan(req->t_first) || req->t_first == 0.)
@@ -724,7 +724,7 @@ VSLb_ts_req(struct req *req, const char *event, double now)
 }
 
 static inline void
-VSLb_ts_busyobj(struct busyobj *bo, const char *event, double now)
+VSLb_ts_busyobj(struct busyobj *bo, const char *event, vtim_real now)
 {
 
 	if (isnan(bo->t_first) || bo->t_first == 0.)
@@ -775,7 +775,7 @@ WS_Front(const struct ws *ws)
 }
 
 /* cache_rfc2616.c */
-void RFC2616_Ttl(struct busyobj *, double now, double *t_origin,
+void RFC2616_Ttl(struct busyobj *, vtim_real now, vtim_real *t_origin,
     float *ttl, float *grace, float *keep);
 unsigned RFC2616_Req_Gzip(const struct http *);
 int RFC2616_Do_Cond(const struct req *sp);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index fab8661cf..a8c9a08c1 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -118,10 +118,10 @@ BAN_Release(void)
  * Extract time and length from ban-spec
  */
 
-double
+vtim_real
 ban_time(const uint8_t *banspec)
 {
-	double t;
+	vtim_real t;
 
 	assert(sizeof t == (BANS_LENGTH - BANS_TIMESTAMP));
 	memcpy(&t, banspec, sizeof t);
@@ -257,10 +257,10 @@ BAN_DestroyObj(struct objcore *oc)
  */
 
 struct ban *
-BAN_FindBan(double t0)
+BAN_FindBan(vtim_real t0)
 {
 	struct ban *b;
-	double t1;
+	vtim_real t1;
 
 	assert(ban_holds > 0);
 	VTAILQ_FOREACH(b, &ban_head, list) {
@@ -358,7 +358,7 @@ ban_reload(const uint8_t *ban, unsigned len)
 {
 	struct ban *b, *b2;
 	int duplicate = 0;
-	double t0, t1, t2 = 9e99;
+	vtim_real t0, t1, t2 = 9e99;
 	ASSERT_CLI();
 	Lck_AssertHeld(&ban_mtx);
 
@@ -440,7 +440,7 @@ BAN_Reload(const uint8_t *ptr, unsigned len)
  * Get a bans timestamp
  */
 
-double
+vtim_real
 BAN_Time(const struct ban *b)
 {
 
diff --git a/bin/varnishd/cache/cache_ban.h b/bin/varnishd/cache/cache_ban.h
index 62fc767bb..1a9420825 100644
--- a/bin/varnishd/cache/cache_ban.h
+++ b/bin/varnishd/cache/cache_ban.h
@@ -116,7 +116,7 @@ void ban_info_drop(const uint8_t *ban, unsigned len);
 
 int ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc,
     const struct http *reqhttp, unsigned *tests);
-double ban_time(const uint8_t *banspec);
+vtim_real ban_time(const uint8_t *banspec);
 int ban_equal(const uint8_t *bs1, const uint8_t *bs2);
 void BAN_Free(struct ban *b);
 void ban_kick_lurker(void);
diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c
index 1ff460057..e3b9873a8 100644
--- a/bin/varnishd/cache/cache_ban_build.c
+++ b/bin/varnishd/cache/cache_ban_build.c
@@ -250,7 +250,7 @@ BAN_Commit(struct ban_proto *bp)
 {
 	struct ban  *b, *bi;
 	ssize_t ln;
-	double t0;
+	vtim_real t0;
 
 	CHECK_OBJ_NOTNULL(bp, BAN_PROTO_MAGIC);
 	AN(bp->vsb);
diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 1729e04a9..febc57ff3 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -315,12 +315,13 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt,
  * completed.
  */
 
-static double
+static vtim_dur
 ban_lurker_work(struct worker *wrk, struct vsl_log *vsl)
 {
 	struct ban *b, *bd;
 	struct banhead_s obans;
-	double d, dt, n;
+	vtim_real d;
+	vtim_dur dt, n;
 	unsigned count = 0, cutoff = UINT_MAX;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -407,7 +408,8 @@ void * v_matchproto_(bgthread_t)
 ban_lurker(struct worker *wrk, void *priv)
 {
 	struct vsl_log vsl;
-	volatile double d;
+	volatile vtim_real d;
+	vtim_dur dt;
 	unsigned gen = ban_generation + 1;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -416,10 +418,10 @@ ban_lurker(struct worker *wrk, void *priv)
 	VSL_Setup(&vsl, NULL, 0);
 
 	while (!ban_shutdown) {
-		d = ban_lurker_work(wrk, &vsl);
+		dt = ban_lurker_work(wrk, &vsl);
 		if (DO_DEBUG(DBG_LURKER))
-			VSLb(&vsl, SLT_Debug, "lurker: sleep = %lf", d);
-		d += VTIM_real();
+			VSLb(&vsl, SLT_Debug, "lurker: sleep = %lf", dt);
+		d = VTIM_real() + dt;
 		Lck_Lock(&ban_mtx);
 		if (gen == ban_generation) {
 			Pool_Sumstat(wrk);
diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h
index bf7c37f24..d4553e150 100644
--- a/bin/varnishd/cache/cache_director.h
+++ b/bin/varnishd/cache/cache_director.h
@@ -39,7 +39,7 @@ struct vcldir {
 	const struct vdi_methods	*methods;
 	VTAILQ_ENTRY(vcldir)		list;
 	const struct vdi_ahealth	*admin_health;
-	double				health_changed;
+	vtim_real			health_changed;
 	char				*cli_name;
 };
 
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 3f2a11caf..85a435741 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -61,10 +61,10 @@ static struct exp_priv *exphdl;
  * if it is available.
  */
 
-double
+vtim_real
 EXP_Ttl(const struct req *req, const struct objcore *oc)
 {
-	double r;
+	vtim_dur r;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
@@ -79,10 +79,10 @@ EXP_Ttl(const struct req *req, const struct objcore *oc)
  * account if it is available.
  */
 
-double
+vtim_real
 EXP_Ttl_grace(const struct req *req, const struct objcore *oc)
 {
-	double g;
+	vtim_dur g;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
@@ -160,9 +160,10 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
  */
 
 void
-EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep)
+EXP_Rearm(struct objcore *oc, vtim_real now,
+    vtim_dur ttl, vtim_dur grace, vtim_dur keep)
 {
-	double when;
+	vtim_real when;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	assert(oc->refcnt > 0);
@@ -245,8 +246,8 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags)
  * Expire stuff from the binheap
  */
 
-static double
-exp_expire(struct exp_priv *ep, double now)
+static vtim_real
+exp_expire(struct exp_priv *ep, vtim_real now)
 {
 	struct objcore *oc;
 
@@ -322,7 +323,7 @@ static void * v_matchproto_(bgthread_t)
 exp_thread(struct worker *wrk, void *priv)
 {
 	struct objcore *oc;
-	double t = 0, tnext = 0;
+	vtim_real t = 0, tnext = 0;
 	struct exp_priv *ep;
 	unsigned flags = 0;
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 9a08a37c6..1056eca9f 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -48,7 +48,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l)
 {
 	struct objcore *oc;
 	const struct stevedore *stv;
-	double lifetime;
+	vtim_dur lifetime;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	oc = bo->fetch_objcore;
@@ -258,7 +258,7 @@ static enum fetch_step
 vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 {
 	int i;
-	double now;
+	vtim_real now;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
@@ -679,7 +679,7 @@ static enum fetch_step
 vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 {
 	ssize_t l, ll, o;
-	double now;
+	vtim_real now;
 	uint8_t *ptr;
 	struct vsb *synth_body;
 
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index bb32d4fc2..d8cd7e332 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -344,7 +344,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 	struct objhead *oh;
 	struct objcore *oc;
 	struct objcore *exp_oc;
-	double exp_t_origin;
+	vtim_real exp_t_origin;
 	int busy_found;
 	enum lookup_e retval;
 	const uint8_t *vary;
@@ -613,8 +613,8 @@ hsh_rush2(struct worker *wrk, struct rush *r)
  */
 
 unsigned
-HSH_Purge(struct worker *wrk, struct objhead *oh, double ttl_now, double ttl,
-double grace, double keep)
+HSH_Purge(struct worker *wrk, struct objhead *oh, vtim_real ttl_now,
+    vtim_dur ttl, vtim_dur grace, vtim_dur keep)
 {
 	struct objcore *oc, **ocp;
 	unsigned spc, ospc, nobj, n, n_tot = 0;
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 23eaa0b18..34cd11a02 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -1228,7 +1228,7 @@ http_PrintfHeader(struct http *to, const char *fmt, ...)
 }
 
 void
-http_TimeHeader(struct http *to, const char *fmt, double now)
+http_TimeHeader(struct http *to, const char *fmt, vtim_real now)
 {
 	char *p;
 
diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
index ad182c4b0..1e6e689ac 100644
--- a/bin/varnishd/cache/cache_lck.c
+++ b/bin/varnishd/cache/cache_lck.c
@@ -191,7 +191,7 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, vtim_real when)
 {
 	struct ilck *ilck;
 	struct timespec ts;
-	double t;
+	vtim_real t;
 
 	CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC);
 	AN(ilck->held);
diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c
index 62407f607..aa7adc0c4 100644
--- a/bin/varnishd/cache/cache_mempool.c
+++ b/bin/varnishd/cache/cache_mempool.c
@@ -44,7 +44,7 @@ struct memitem {
 #define MEMITEM_MAGIC			0x42e55401
 	unsigned			size;
 	VTAILQ_ENTRY(memitem)		list;
-	double				touched;
+	vtim_real			touched;	// XXX -> mono?
 };
 
 VTAILQ_HEAD(memhead_s, memitem);
@@ -63,7 +63,7 @@ struct mempool {
 	struct VSC_mempool		*vsc;
 	unsigned			n_pool;
 	pthread_t			thread;
-	double				t_now;
+	vtim_real			t_now;	// XXX -> mono?
 	int				self_destruct;
 };
 
@@ -99,8 +99,8 @@ mpl_guard(void *priv)
 {
 	struct mempool *mpl;
 	struct memitem *mi = NULL;
-	double v_statevariable_(mpl_slp);
-	double last = 0;
+	vtim_dur v_statevariable_(mpl_slp);
+	vtim_real last = 0;
 
 	CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC);
 	THR_SetName(mpl->name);
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index a3f2d182e..77a3771a7 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -481,7 +481,7 @@ ObjSetAttr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
  */
 
 void
-ObjTouch(struct worker *wrk, struct objcore *oc, double now)
+ObjTouch(struct worker *wrk, struct objcore *oc, vtim_real now)
 {
 	const struct obj_methods *om = obj_getmethods(oc);
 
diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h
index 6bcb7b301..81bba4da0 100644
--- a/bin/varnishd/cache/cache_objhead.h
+++ b/bin/varnishd/cache/cache_objhead.h
@@ -72,7 +72,7 @@ enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
     int always_insert);
 void HSH_Ref(struct objcore *o);
 void HSH_AddString(struct req *, void *ctx, const char *str);
-unsigned HSH_Purge(struct worker *, struct objhead *, double ttl_now,
-    double ttl, double grace, double keep);
+unsigned HSH_Purge(struct worker *, struct objhead *, vtim_dur ttl_now,
+    vtim_dur ttl, vtim_dur grace, vtim_dur keep);
 struct objcore *HSH_Private(const struct worker *wrk);
 void HSH_Abandon(struct objcore *oc);
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 0654b9f6b..791fa30b8 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -107,9 +107,9 @@ void VBP_Init(void);
 void BAN_Hold(void);
 void BAN_Release(void);
 void BAN_Reload(const uint8_t *ban, unsigned len);
-struct ban *BAN_FindBan(double t0);
+struct ban *BAN_FindBan(vtim_real t0);
 void BAN_RefBan(struct objcore *oc, struct ban *);
-double BAN_Time(const struct ban *ban);
+vtim_real BAN_Time(const struct ban *ban);
 
 /* cache_busyobj.c */
 struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
@@ -125,8 +125,8 @@ void VDI_Event(const struct director *d, enum vcl_event_e ev);
 void VDI_Init(void);
 
 /* cache_exp.c */
-double EXP_Ttl(const struct req *, const struct objcore *);
-double EXP_Ttl_grace(const struct req *, const struct objcore *oc);
+vtim_real EXP_Ttl(const struct req *, const struct objcore *);
+vtim_real EXP_Ttl_grace(const struct req *, const struct objcore *oc);
 void EXP_Insert(struct worker *wrk, struct objcore *oc);
 void EXP_Remove(struct objcore *);
 
@@ -161,9 +161,8 @@ void EXP_Remove(struct objcore *);
 	((to)->t_origin + (to)->ttl + (to)->grace + (to)->keep)
 
 /* cache_exp.c */
-void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
-    double keep);
-
+void EXP_Rearm(struct objcore *oc, vtim_real now,
+    vtim_dur ttl, vtim_dur grace, vtim_dur keep);
 
 /* From cache_main.c */
 void BAN_Init(void);
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 212142ceb..0db48e3de 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -139,10 +139,10 @@ uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity,
 /*--------------------------------------------------------------------*/
 struct lru *LRU_Alloc(void);
 void LRU_Free(struct lru **);
-void LRU_Add(struct objcore *, double now);
+void LRU_Add(struct objcore *, vtim_real now);
 void LRU_Remove(struct objcore *);
 int LRU_NukeOne(struct worker *, struct lru *);
-void LRU_Touch(struct worker *, struct objcore *, double now);
+void LRU_Touch(struct worker *, struct objcore *, vtim_real now);
 
 /*--------------------------------------------------------------------*/
 extern const struct stevedore smu_stevedore;
diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c
index d5dcf6a68..381612bb8 100644
--- a/bin/varnishd/storage/storage_lru.c
+++ b/bin/varnishd/storage/storage_lru.c
@@ -79,7 +79,7 @@ LRU_Free(struct lru **pp)
 }
 
 void
-LRU_Add(struct objcore *oc, double now)
+LRU_Add(struct objcore *oc, vtim_real now)
 {
 	struct lru *lru;
 
@@ -121,7 +121,7 @@ LRU_Remove(struct objcore *oc)
 }
 
 void v_matchproto_(objtouch_f)
-LRU_Touch(struct worker *wrk, struct objcore *oc, double now)
+LRU_Touch(struct worker *wrk, struct objcore *oc, vtim_real now)
 {
 	struct lru *lru;
 


More information about the varnish-commit mailing list