[master] 1dc9a5c Move eviction to the common pipe implementation
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jan 15 11:29:02 CET 2015
commit 1dc9a5cef5aae77bc377788fa8c66272303d11db
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jan 15 10:27:27 2015 +0000
Move eviction to the common pipe implementation
diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c
index ef36346..c5fed78 100644
--- a/bin/varnishd/waiter/cache_waiter.c
+++ b/bin/varnishd/waiter/cache_waiter.c
@@ -105,6 +105,7 @@ WAIT_Enter(const struct waiter *w, struct waited *wp)
if (w->impl->pass != NULL)
return (w->impl->pass(w->priv, wp));
+
assert(w->pfd >= 0);
written = write(w->pfd, &wp, sizeof wp);
@@ -136,6 +137,8 @@ WAIT_handle(struct waiter *w, struct waited *wp, enum wait_event ev, double now)
AZ(i);
return;
}
+ if (w->impl->evict != NULL)
+ w->impl->evict(w, wp);
VTAILQ_REMOVE(&w->sesshead, wp, list);
w->func(wp, ev, now);
diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c
index ddb2107..44beabc 100644
--- a/bin/varnishd/waiter/cache_waiter_poll.c
+++ b/bin/varnishd/waiter/cache_waiter_poll.c
@@ -79,14 +79,18 @@ vwp_pollspace(struct vwp *vwp, unsigned fd)
/*--------------------------------------------------------------------*/
-static void
-vwp_poll(struct vwp *vwp, int fd)
+static void __match_proto__(waiter_inject_f)
+vwp_inject(const struct waiter *w, struct waited *wp)
{
+ struct vwp *vwp;
+ int fd;
+ CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC);
+ CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC);
+ fd = wp->fd;
assert(fd >= 0);
vwp_pollspace(vwp, (unsigned)fd);
assert(fd < vwp->npoll);
-
if (vwp->hpoll < fd)
vwp->hpoll = fd;
@@ -98,19 +102,15 @@ vwp_poll(struct vwp *vwp, int fd)
vwp->pollfd[fd].events = POLLIN;
}
-static void __match_proto__(waiter_inject_f)
-vwp_inject(const struct waiter *w, struct waited *wp)
+static void __match_proto__(waiter_evict_f)
+vwp_evict(const struct waiter *w, struct waited *wp)
{
struct vwp *vwp;
+ int fd;
CAST_OBJ_NOTNULL(vwp, w->priv, VWP_MAGIC);
- vwp_poll(vwp, wp->fd);
-}
-
-static void
-vwp_unpoll(struct vwp *vwp, int fd)
-{
-
+ CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC);
+ fd = wp->fd;
assert(fd >= 0);
assert(fd < vwp->npoll);
vwp_pollspace(vwp, (unsigned)fd);
@@ -158,12 +158,9 @@ vwp_main(void *priv)
if (vwp->pollfd[fd].revents) {
v2--;
vwp->pollfd[fd].revents = 0;
- if (sp != vwp->waiter->pipe_w)
- vwp_unpoll(vwp, fd);
WAIT_handle(vwp->waiter, sp, WAITER_ACTION,
now);
} else if (sp->deadline <= deadline) {
- vwp_unpoll(vwp, fd);
WAIT_handle(vwp->waiter, sp, WAITER_TIMEOUT,
now);
}
@@ -195,5 +192,6 @@ const struct waiter_impl waiter_poll = {
.name = "poll",
.init = vwp_poll_init,
.inject = vwp_inject,
+ .evict = vwp_evict,
.size = sizeof(struct vwp),
};
diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c
index 54c3c34..b9f8960 100644
--- a/bin/varnishd/waiter/mgt_waiter.c
+++ b/bin/varnishd/waiter/mgt_waiter.c
@@ -40,7 +40,7 @@
static const struct waiter_impl *const waiter_impls[] = {
#if defined(HAVE_KQUEUE)
- &waiter_kqueue,
+ // &waiter_kqueue,
#endif
#if defined(HAVE_EPOLL_CTL)
&waiter_epoll,
diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h
index 35a8db6..a277327 100644
--- a/bin/varnishd/waiter/waiter_priv.h
+++ b/bin/varnishd/waiter/waiter_priv.h
@@ -50,12 +50,14 @@ struct waiter {
typedef void waiter_init_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 *);
struct waiter_impl {
const char *name;
waiter_init_f *init;
waiter_pass_f *pass;
waiter_inject_f *inject;
+ waiter_evict_f *evict;
size_t size;
};
More information about the varnish-commit
mailing list