[master] 8ff174a Add a pointer arg for waiter->init to generalize the handling for waiters which pass over a pipe.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 12 14:36:40 CET 2015
commit 8ff174a4ebe6d6f16eabb8b8396e1f0c218e518f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 12 12:49:49 2015 +0000
Add a pointer arg for waiter->init to generalize the handling
for waiters which pass over a pipe.
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index 1313766..8214b71 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -44,6 +44,7 @@ struct waiter {
#define WAITER_MAGIC 0x17c399db
const struct waiter_impl *impl;
void *priv;
+ int pfd;
};
const char *
@@ -63,13 +64,14 @@ WAIT_Init(waiter_handle_f *func)
ALLOC_OBJ(w, WAITER_MAGIC);
AN(w);
+ w->pfd = -1;
AN(waiter);
AN(waiter->name);
AN(waiter->init);
- AN(waiter->pass);
w->impl = waiter;
- w->priv = w->impl->init(func);
+ w->priv = w->impl->init(func, &w->pfd);
+ AN(waiter->pass || w->pfd >= 0);
return (w);
}
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index bc4573d..082422f 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -233,12 +233,13 @@ vwe_pass(void *priv, struct sess *sp)
/*--------------------------------------------------------------------*/
-static void *
-vwe_init(waiter_handle_f *func)
+static void * __match_proto__(waiter_init_f)
+vwe_init(waiter_handle_f *func, int *pfd)
{
struct vwe *vwe;
AN(func);
+ AN(pfd);
ALLOC_OBJ(vwe, VWE_MAGIC);
AN(vwe);
VTAILQ_INIT(&vwe->sesshead);
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index d1f5a79..a1950f7 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -228,12 +228,13 @@ vwk_pass(void *priv, struct sess *sp)
/*--------------------------------------------------------------------*/
-static void *
-vwk_init(waiter_handle_f *func)
+static void * __match_proto__(waiter_init_f)
+vwk_init(waiter_handle_f *func, int *pfd)
{
struct vwk *vwk;
AN(func);
+ AN(pfd);
ALLOC_OBJ(vwk, VWK_MAGIC);
AN(vwk);
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index 3a10b26..ef3426f 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -205,12 +205,13 @@ vwp_poll_pass(void *priv, struct sess *sp)
/*--------------------------------------------------------------------*/
-static void *
-vwp_poll_init(waiter_handle_f *func)
+static void * __match_proto__(waiter_init_f)
+vwp_poll_init(waiter_handle_f *func, int *pfd)
{
struct vwp *vwp;
AN(func);
+ AN(pfd);
ALLOC_OBJ(vwp, VWP_MAGIC);
AN(vwp);
VTAILQ_INIT(&vwp->sesshead);
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index 9f5a13f..d9c55b4 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -256,12 +256,13 @@ vws_pass(void *priv, struct sess *sp)
/*--------------------------------------------------------------------*/
-static void *
-vws_init(waiter_handle_f *func)
+static void * __match_proto__(waiter_init_f)
+vws_init(waiter_handle_f *func, int *pfd)
{
struct vws *vws;
AN(func);
+ AN(pfd);
ALLOC_OBJ(vws, VWS_MAGIC);
AN(vws);
vws->func = func;
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
index 7d6cbac..218eca5 100644
--- a/bin/varnishd/waiter/waiter.h
+++ b/bin/varnishd/waiter/waiter.h
@@ -38,7 +38,7 @@ enum wait_event {
};
typedef void waiter_handle_f(void *ptr, int fd, enum wait_event, double now);
-typedef void* waiter_init_f(waiter_handle_f *);
+typedef void* waiter_init_f(waiter_handle_f *, int *);
typedef int waiter_pass_f(void *priv, struct sess *);
#define WAITER_DEFAULT "platform dependent"
More information about the varnish-commit
mailing list