Commit 8ff174a4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a pointer arg for waiter->init to generalize the handling

for waiters which pass over a pipe.
parent bbf9e25b
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment