[master] f1da3c4 Implement "struct waiter" for a waiter instance
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 12 13:21:48 CET 2015
commit f1da3c43a8709321962ac2d3dbdf91a26cf99ad1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 12 12:21:33 2015 +0000
Implement "struct waiter" for a waiter instance
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 0034203..e0fec6e 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -60,7 +60,7 @@ struct sesspool {
struct mempool *mpl_req;
struct mempool *mpl_sess;
- void *http1_waiter;
+ struct waiter *http1_waiter;
};
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index 7f457e5..af01124 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -30,6 +30,7 @@
#include "config.h"
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
@@ -38,6 +39,13 @@
#include "waiter/waiter.h"
+struct waiter {
+ unsigned magic;
+#define WAITER_MAGIC 0x17c399db
+ const struct waiter_impl *impl;
+ void *priv;
+};
+
const char *
WAIT_GetName(void)
{
@@ -48,25 +56,32 @@ WAIT_GetName(void)
return ("no_waiter");
}
-void *
+struct waiter *
WAIT_Init(waiter_handle_f *func)
{
+ struct waiter *w;
+
+ ALLOC_OBJ(w, WAITER_MAGIC);
+ AN(w);
AN(waiter);
AN(waiter->name);
AN(waiter->init);
AN(waiter->pass);
- return (waiter->init(func));
+ w->impl = waiter;
+ w->priv = w->impl->init(func);
+ return (w);
}
int
-WAIT_Enter(void *waiter_priv, struct sess *sp)
+WAIT_Enter(const struct waiter *w, struct sess *sp)
{
+ CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(sp->fd >= 0);
- return (waiter->pass(waiter_priv, sp));
+ return (w->impl->pass(w->priv, sp));
}
/*
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
index 5ea4720..902356d 100644
--- a/bin/varnishd/waiter/waiter.h
+++ b/bin/varnishd/waiter/waiter.h
@@ -29,6 +29,7 @@
*/
struct sess;
+struct waiter;
enum wait_event {
WAITER_REMCLOSE,
@@ -49,8 +50,8 @@ struct waiter_impl {
};
/* cache_waiter.c */
-int WAIT_Enter(void *waiter_priv, struct sess *sp);
-void *WAIT_Init(waiter_handle_f *);
+int WAIT_Enter(const struct waiter *, struct sess *sp);
+struct waiter *WAIT_Init(waiter_handle_f *);
const char *WAIT_GetName(void);
int WAIT_Write_Session(struct sess *sp, int fd);
More information about the varnish-commit
mailing list