[master] d034148 Add the scaffolding for destroying waiters, now I just need to make it also work.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jan 21 09:35:53 CET 2015
commit d03414855ed325464db5e42faeb7d62ed113b3d9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jan 21 08:35:22 2015 +0000
Add the scaffolding for destroying waiters, now I just need to make it
also work.
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index 4f71f96..1629625 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -112,6 +112,8 @@ Wait_New(waiter_handle_f *func, volatile double *tmo)
Lck_Lock(&wait_mtx);
VTAILQ_INSERT_TAIL(&waiters, w, list);
nwaiters++;
+
+ /* We assume all waiters either use pipes or don't use pipes */
if (w->pipes[1] >= 0 && nwaiters == 1)
AZ(pthread_create(&wait_thr, NULL, wait_poker_thread, NULL));
Lck_Unlock(&wait_mtx);
@@ -119,6 +121,19 @@ Wait_New(waiter_handle_f *func, volatile double *tmo)
}
void
+Wait_Destroy(struct waiter **wp)
+{
+ struct waiter *w;
+
+ AN(wp);
+ w = *wp;
+ *wp = NULL;
+ CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
+ AN(w->impl->fini);
+ w->impl->fini(w);
+}
+
+void
Wait_UsePipe(struct waiter *w)
{
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h
index ee4b6bc..8b52b6b 100644
--- a/bin/varnishd/waiter/waiter.h
+++ b/bin/varnishd/waiter/waiter.h
@@ -58,6 +58,7 @@ typedef void waiter_handle_f(struct waited *, enum wait_event, double now);
/* cache_waiter.c */
int Wait_Enter(const struct waiter *, struct waited *);
struct waiter *Wait_New(waiter_handle_f *, volatile double *timeout);
+void Wait_Destroy(struct waiter **);
const char *Wait_GetName(void);
void Wait_Init(void);
diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h
index 14b5e6f..f18dd7e 100644
--- a/bin/varnishd/waiter/waiter_priv.h
+++ b/bin/varnishd/waiter/waiter_priv.h
@@ -50,6 +50,7 @@ struct waiter {
};
typedef void waiter_init_f(struct waiter *);
+typedef void waiter_fini_f(struct waiter *);
typedef int waiter_pass_f(void *priv, struct waited *);
typedef void waiter_inject_f(const struct waiter *, struct waited *);
typedef void waiter_evict_f(const struct waiter *, struct waited *);
@@ -57,6 +58,7 @@ typedef void waiter_evict_f(const struct waiter *, struct waited *);
struct waiter_impl {
const char *name;
waiter_init_f *init;
+ waiter_fini_f *fini;
waiter_pass_f *pass;
waiter_inject_f *inject;
waiter_evict_f *evict;
More information about the varnish-commit
mailing list