[master] a82d8552f fix type of (struct waited).tmo and make it immediate

Nils Goroll nils.goroll at uplex.de
Sat Apr 20 14:45:09 UTC 2019


commit a82d8552fc9f612b2295c357a256f896c6168368
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sat Apr 20 16:39:09 2019 +0200

    fix type of (struct waited).tmo and make it immediate
    
    the pointer indirection would make sense if we had any long lived struct
    waited instances so the timeout parameter could change. But we don't.
    
    Also the vtim_ type was wrong, it is a duration.

diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 8c9e2d7c9..95696d4eb 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -465,7 +465,7 @@ SES_Wait(struct sess *sp, const struct transport *xp)
 	wp->priv2 = (uintptr_t)xp;
 	wp->idle = sp->t_idle;
 	wp->func = ses_handle;
-	wp->tmo = &cache_param->timeout_idle;
+	wp->tmo = cache_param->timeout_idle;
 	if (Wait_Enter(pp->waiter, wp))
 		SES_Delete(sp, SC_PIPE_OVERFLOW, NAN);
 }
diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index 0e2fbd4f7..63691b91b 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -338,7 +338,7 @@ VCP_Recycle(const struct worker *wrk, struct pfd **pfdp)
 	pfd->waited->idle = VTIM_real();
 	pfd->state = PFD_STATE_AVAIL;
 	pfd->waited->func = vcp_handle;
-	pfd->waited->tmo = &cache_param->backend_idle_timeout;
+	pfd->waited->tmo = cache_param->backend_idle_timeout;
 	if (Wait_Enter(wrk->pool->waiter, pfd->waited)) {
 		cp->methods->close(pfd);
 		memset(pfd, 0x33, sizeof *pfd);
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index d481358bb..80a0deb9f 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -133,7 +133,6 @@ Wait_Enter(const struct waiter *w, struct waited *wp)
 	CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC);
 	assert(wp->fd > 0);			// stdin never comes here
 	AN(wp->func);
-	AN(wp->tmo);
 	wp->idx = BINHEAP_NOIDX;
 	return (w->impl->enter(w->priv, wp));
 }
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
index 4a0d8a7d5..cbdf6a6d6 100644
--- a/bin/varnishd/waiter/waiter.h
+++ b/bin/varnishd/waiter/waiter.h
@@ -62,7 +62,7 @@ struct waited {
 	void			*priv1;
 	uintptr_t		priv2;
 	waiter_handle_f		*func;
-	volatile vtim_real	*tmo;
+	vtim_dur		tmo;
 	vtim_real		idle;
 };
 
diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h
index bdf0d23af..8ef498613 100644
--- a/bin/varnishd/waiter/waiter_priv.h
+++ b/bin/varnishd/waiter/waiter_priv.h
@@ -62,8 +62,7 @@ static inline double
 Wait_When(const struct waited *wp)
 {
 	CHECK_OBJ_ORNULL(wp, WAITED_MAGIC);
-	AN(wp->tmo);
-	return (wp->idle + *wp->tmo);
+	return (wp->idle + wp->tmo);
 }
 
 void Wait_Call(const struct waiter *, struct waited *,


More information about the varnish-commit mailing list