[master] 07cf9e5 unify the waiter->pass for the common case

Poul-Henning Kamp phk at FreeBSD.org
Mon Jan 12 14:36:40 CET 2015


commit 07cf9e50ce4e921fbcab26228c0ba4ea40b74f95
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 12 13:05:41 2015 +0000

    unify the waiter->pass for the common case

diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index 8214b71..93ce37c 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -85,7 +85,10 @@ WAIT_Enter(const struct waiter *w, void *ptr, int fd)
 	assert(fd >= 0);
 	assert(sp->fd >= 0);
 
-	return (w->impl->pass(w->priv, sp));
+	if (w->impl->pass != NULL)
+		return (w->impl->pass(w->priv, sp));
+	assert(w->pfd >= 0);
+	return (WAIT_Write_Session(sp, w->pfd));
 }
 
 /*
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index 082422f..67f6ce6 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -221,18 +221,6 @@ vwe_timeout_idle_ticker(void *priv)
 
 /*--------------------------------------------------------------------*/
 
-static int
-vwe_pass(void *priv, struct sess *sp)
-{
-	struct vwe *vwe;
-
-	CAST_OBJ_NOTNULL(vwe, priv, VWE_MAGIC);
-
-	return (WAIT_Write_Session(sp, vwe->pipes[1]));
-}
-
-/*--------------------------------------------------------------------*/
-
 static void * __match_proto__(waiter_init_f)
 vwe_init(waiter_handle_f *func, int *pfd)
 {
@@ -251,6 +239,7 @@ vwe_init(waiter_handle_f *func, int *pfd)
 	AZ(VFIL_nonblocking(vwe->timer_pipes[0]));
 
 	vwe->func = func;
+	*pfd = vwe->pipes[1];
 
 	AZ(pthread_create(&vwe->timer_thread,
 	    NULL, vwe_timeout_idle_ticker, vwe));
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index a1950f7..7533109 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -216,18 +216,6 @@ vwk_thread(void *priv)
 
 /*--------------------------------------------------------------------*/
 
-static int
-vwk_pass(void *priv, struct sess *sp)
-{
-	struct vwk *vwk;
-
-	CAST_OBJ_NOTNULL(vwk, priv, VWK_MAGIC);
-
-	return (WAIT_Write_Session(sp, vwk->pipes[1]));
-}
-
-/*--------------------------------------------------------------------*/
-
 static void * __match_proto__(waiter_init_f)
 vwk_init(waiter_handle_f *func, int *pfd)
 {
@@ -245,6 +233,7 @@ vwk_init(waiter_handle_f *func, int *pfd)
 
 	AZ(VFIL_nonblocking(vwk->pipes[0]));
 	AZ(VFIL_nonblocking(vwk->pipes[1]));
+	*pfd = vwk->pipes[1];
 
 	AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk));
 	return (vwk);
@@ -255,7 +244,6 @@ vwk_init(waiter_handle_f *func, int *pfd)
 const struct waiter_impl waiter_kqueue = {
 	.name =		"kqueue",
 	.init =		vwk_init,
-	.pass =		vwk_pass,
 };
 
 #endif /* defined(HAVE_KQUEUE) */
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index ef3426f..37413d3 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -193,18 +193,6 @@ vwp_main(void *priv)
 
 /*--------------------------------------------------------------------*/
 
-static int
-vwp_poll_pass(void *priv, struct sess *sp)
-{
-	struct vwp *vwp;
-
-	CAST_OBJ_NOTNULL(vwp, priv, VWP_MAGIC);
-
-	return (WAIT_Write_Session(sp, vwp->pipes[1]));
-}
-
-/*--------------------------------------------------------------------*/
-
 static void * __match_proto__(waiter_init_f)
 vwp_poll_init(waiter_handle_f *func, int *pfd)
 {
@@ -220,6 +208,7 @@ vwp_poll_init(waiter_handle_f *func, int *pfd)
 	vwp->func = func;
 
 	AZ(VFIL_nonblocking(vwp->pipes[1]));
+	*pfd = vwp->pipes[1];
 
 	vwp_pollspace(vwp, 256);
 	AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp));
@@ -231,5 +220,4 @@ vwp_poll_init(waiter_handle_f *func, int *pfd)
 const struct waiter_impl waiter_poll = {
 	.name =		"poll",
 	.init =		vwp_poll_init,
-	.pass =		vwp_poll_pass,
 };



More information about the varnish-commit mailing list