[master] 777bbff Slight shuffling of deskchairs.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jan 14 10:24:13 CET 2015
commit 777bbffc9da811016bab90a34621e3f2626039cb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jan 14 09:23:51 2015 +0000
Slight shuffling of deskchairs.
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index 82f2175..e44b896 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -55,16 +55,12 @@ WAIT_Init(waiter_handle_f *func, volatile double *tmo)
{
struct waiter *w;
- ALLOC_OBJ(w, WAITER_MAGIC);
- AN(w);
- w->pfd = -1;
-
AN(waiter);
AN(waiter->name);
AN(waiter->init);
+ w = waiter->init(func, tmo);
w->impl = waiter;
- w->priv = w->impl->init(func, &w->pfd, tmo);
- AN(waiter->pass || w->pfd >= 0);
+ AN(w->impl->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 6c25918..8a753f4 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -55,6 +55,7 @@
struct vwe {
unsigned magic;
#define VWE_MAGIC 0x6bd73424
+ struct waiter waiter[1];
pthread_t epoll_thread;
pthread_t timer_thread;
@@ -215,18 +216,19 @@ vwe_timeout_idle_ticker(void *priv)
/*--------------------------------------------------------------------*/
-static void * __match_proto__(waiter_init_f)
-vwe_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
+static struct waiter * __match_proto__(waiter_init_f)
+vwe_init(waiter_handle_f *func, volatile double *tmo)
{
struct vwe *vwe;
AN(func);
- AN(pfd);
AN(tmo);
ALLOC_OBJ(vwe, VWE_MAGIC);
AN(vwe);
+ INIT_OBJ(vwe->waiter, WAITER_MAGIC);
+
VTAILQ_INIT(&vwe->sesshead);
AZ(pipe(vwe->pipes));
AZ(pipe(vwe->timer_pipes));
@@ -237,12 +239,12 @@ vwe_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
vwe->func = func;
vwe->tmo = tmo;
- *pfd = vwe->pipes[1];
+ vwe->waiter->pfd = vwe->pipes[1];
AZ(pthread_create(&vwe->timer_thread,
NULL, vwe_timeout_idle_ticker, vwe));
AZ(pthread_create(&vwe->epoll_thread, NULL, vwe_thread, vwe));
- return(vwe);
+ return(vwe->waiter);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c
index 162c799..77c41e4 100644
--- a/bin/varnishd/waiter/cache_waiter_kqueue.c
+++ b/bin/varnishd/waiter/cache_waiter_kqueue.c
@@ -53,6 +53,8 @@
struct vwk {
unsigned magic;
#define VWK_MAGIC 0x1cc2acc2
+ struct waiter waiter[1];
+
waiter_handle_f *func;
volatile double *tmo;
pthread_t thread;
@@ -211,17 +213,18 @@ vwk_thread(void *priv)
/*--------------------------------------------------------------------*/
-static void * __match_proto__(waiter_init_f)
-vwk_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
+static struct waiter * __match_proto__(waiter_init_f)
+vwk_init(waiter_handle_f *func, volatile double *tmo)
{
struct vwk *vwk;
AN(func);
- AN(pfd);
AN(tmo);
ALLOC_OBJ(vwk, VWK_MAGIC);
AN(vwk);
+ INIT_OBJ(vwk->waiter, WAITER_MAGIC);
+
vwk->func = func;
vwk->tmo = tmo;
@@ -230,10 +233,10 @@ vwk_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
AZ(VFIL_nonblocking(vwk->pipes[0]));
AZ(VFIL_nonblocking(vwk->pipes[1]));
- *pfd = vwk->pipes[1];
+ vwk->waiter->pfd = vwk->pipes[1];
AZ(pthread_create(&vwk->thread, NULL, vwk_thread, vwk));
- return (vwk);
+ return (vwk->waiter);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index 9029007..bb8e791 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -46,6 +46,8 @@
struct vwp {
unsigned magic;
#define VWP_MAGIC 0x4b2cc735
+ struct waiter waiter[1];
+
waiter_handle_f *func;
volatile double *tmo;
int pipes[2];
@@ -195,15 +197,16 @@ vwp_main(void *priv)
/*--------------------------------------------------------------------*/
-static void * __match_proto__(waiter_init_f)
-vwp_poll_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
+static struct waiter * __match_proto__(waiter_init_f)
+vwp_poll_init(waiter_handle_f *func, volatile double *tmo)
{
struct vwp *vwp;
AN(func);
- AN(pfd);
ALLOC_OBJ(vwp, VWP_MAGIC);
AN(vwp);
+ INIT_OBJ(vwp->waiter, WAITER_MAGIC);
+
VTAILQ_INIT(&vwp->sesshead);
AZ(pipe(vwp->pipes));
@@ -211,11 +214,11 @@ vwp_poll_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
vwp->tmo = tmo;
AZ(VFIL_nonblocking(vwp->pipes[1]));
- *pfd = vwp->pipes[1];
+ vwp->waiter->pfd = vwp->pipes[1];
vwp_pollspace(vwp, 256);
AZ(pthread_create(&vwp->poll_thread, NULL, vwp_main, vwp));
- return (vwp);
+ return (vwp->waiter);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c
index 6599ea3..ab764c2 100644
--- a/bin/varnishd/waiter/cache_waiter_ports.c
+++ b/bin/varnishd/waiter/cache_waiter_ports.c
@@ -51,6 +51,8 @@
struct vws {
unsigned magic;
#define VWS_MAGIC 0x0b771473
+ struct waiter waiter[1];
+
waiter_handle_f *func;
volatile double *tmo;
pthread_t ports_thread;
@@ -257,21 +259,22 @@ vws_pass(void *priv, struct waited *sp)
/*--------------------------------------------------------------------*/
-static void * __match_proto__(waiter_init_f)
-vws_init(waiter_handle_f *func, int *pfd, volatile double *tmo)
+static struct waiter * __match_proto__(waiter_init_f)
+vws_init(waiter_handle_f *func, volatile double *tmo)
{
struct vws *vws;
AN(func);
- AN(pfd);
AN(tmo);
ALLOC_OBJ(vws, VWS_MAGIC);
AN(vws);
+ INIT_OBJ(vws->waiter, WAITER_MAGIC);
+
vws->func = func;
vws->tmo = tmo;
VTAILQ_INIT(&vws->sesshead);
AZ(pthread_create(&vws->ports_thread, NULL, vws_thread, vws));
- return (vws);
+ return (vws->waiter);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h
index afa8cf0..b397bba 100644
--- a/bin/varnishd/waiter/waiter_priv.h
+++ b/bin/varnishd/waiter/waiter_priv.h
@@ -39,7 +39,7 @@ struct waiter {
int pfd;
};
-typedef void* waiter_init_f(waiter_handle_f *, int *, volatile double *);
+typedef struct waiter* waiter_init_f(waiter_handle_f *, volatile double *);
typedef int waiter_pass_f(void *priv, struct waited *);
struct waiter_impl {
More information about the varnish-commit
mailing list