]> err.no Git - varnish/commitdiff
Retire mgt_event.[ch] and use instead the (new) copy of it in libvarnish.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 11 Jul 2008 21:34:17 +0000 (21:34 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 11 Jul 2008 21:34:17 +0000 (21:34 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2940 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/Makefile.am
varnish-cache/bin/varnishd/cache_backend_poll.c
varnish-cache/bin/varnishd/mgt.h
varnish-cache/bin/varnishd/mgt_child.c
varnish-cache/bin/varnishd/mgt_cli.c
varnish-cache/bin/varnishd/mgt_event.c [deleted file]
varnish-cache/bin/varnishd/mgt_event.h [deleted file]

index 7f5ea9c1a55bf97c2553533224744269336a1720..770cf98e4da9c84da6d2cae688cc67160b5c8f54 100644 (file)
@@ -43,7 +43,6 @@ varnishd_SOURCES = \
        instance.c \
        mgt_child.c \
        mgt_cli.c \
-       mgt_event.c \
        mgt_param.c \
        mgt_vcc.c \
        rfc2616.c \
@@ -63,7 +62,6 @@ noinst_HEADERS = \
        heritage.h \
        mgt.h \
        mgt_cli.h \
-       mgt_event.h \
        steps.h \
        stevedore.h
 
index 83f8cf9b3c97437e3be3222cd74ab3088388a84d..72ad98e31791b1e163267a1d949b2d7b4115c29f 100644 (file)
@@ -49,7 +49,6 @@
 
 #include "shmlog.h"
 #include "cache.h"
-#include "mgt_event.h"
 #include "vrt.h"
 #include "cache_backend.h"
 
index 9b8dc2bd65709a0f25507c609452cf2fa7b9cdc0..10af2f8f270c843c55cb46325475f937a2b79ccd 100644 (file)
@@ -36,7 +36,7 @@
 
 struct cli;
 
-extern struct evbase   *mgt_evb;
+extern struct vev_base *mgt_evb;
 
 /* mgt_child.c */
 void mgt_run(int dflag, const char *T_arg);
index cdfb62f715ce1b0f1ccd8ab964b58b5937e46c9f..6fd8d0b0fb29a81586909f7d56e255104e995a92 100644 (file)
@@ -54,7 +54,7 @@
 #include "cli.h"
 #include "cli_priv.h"
 #include "mgt_cli.h"
-#include "mgt_event.h"
+#include "vev.h"
 #include "vlu.h"
 #include "vsb.h"
 #include "vss.h"
@@ -85,9 +85,9 @@ static const char *ch_state[] = {
        [CH_DIED] =     "died, (restarting)",
 };
 
-struct evbase          *mgt_evb;
-static struct ev       *ev_poker;
-static struct ev       *ev_listen;
+struct vev_base                *mgt_evb;
+static struct vev      *ev_poker;
+static struct vev      *ev_listen;
 static struct vlu      *vlu;
 
 /*--------------------------------------------------------------------
@@ -136,7 +136,7 @@ child_line(void *priv, const char *p)
 /*--------------------------------------------------------------------*/
 
 static int
-child_listener(const struct ev *e, int what)
+child_listener(const struct vev *e, int what)
 {
 
        (void)e;
@@ -154,7 +154,7 @@ child_listener(const struct ev *e, int what)
 /*--------------------------------------------------------------------*/
 
 static int
-child_poker(const struct ev *e, int what)
+child_poker(const struct vev *e, int what)
 {
 
        (void)e;
@@ -228,7 +228,7 @@ start_child(void)
        pid_t pid;
        unsigned u;
        char *p;
-       struct ev *e;
+       struct vev *e;
        int i, cp[2];
 
        if (child_state != CH_STOPPED && child_state != CH_DIED)
@@ -316,23 +316,23 @@ start_child(void)
        AN(vlu);
 
        AZ(ev_listen);
-       e = ev_new();
+       e = vev_new();
        XXXAN(e);
        e->fd = child_output;
        e->fd_flags = EV_RD;
        e->name = "Child listener";
        e->callback = child_listener;
-       AZ(ev_add(mgt_evb, e));
+       AZ(vev_add(mgt_evb, e));
        ev_listen = e;
 
        AZ(ev_poker);
        if (params->ping_interval > 0) {
-               e = ev_new();
+               e = vev_new();
                XXXAN(e);
                e->timeout = params->ping_interval;
                e->callback = child_poker;
                e->name = "child poker";
-               AZ(ev_add(mgt_evb, e));
+               AZ(vev_add(mgt_evb, e));
                ev_poker = e;
        }
 
@@ -361,7 +361,7 @@ mgt_stop_child(void)
 
        REPORT0(LOG_DEBUG, "Stopping Child");
        if (ev_poker != NULL) {
-               ev_del(mgt_evb, ev_poker);
+               vev_del(mgt_evb, ev_poker);
                free(ev_poker);
        }
        ev_poker = NULL;
@@ -376,7 +376,7 @@ mgt_stop_child(void)
 /*--------------------------------------------------------------------*/
 
 static int
-mgt_sigchld(const struct ev *e, int what)
+mgt_sigchld(const struct vev *e, int what)
 {
        int status;
        struct vsb *vsb;
@@ -386,7 +386,7 @@ mgt_sigchld(const struct ev *e, int what)
        (void)what;
 
        if (ev_poker != NULL) {
-               ev_del(mgt_evb, ev_poker);
+               vev_del(mgt_evb, ev_poker);
                free(ev_poker);
        }
        ev_poker = NULL;
@@ -421,7 +421,7 @@ mgt_sigchld(const struct ev *e, int what)
        }
 
        if (ev_listen != NULL) {
-               ev_del(mgt_evb, ev_listen);
+               vev_del(mgt_evb, ev_listen);
                free(ev_listen);
                ev_listen = NULL;
        }
@@ -443,7 +443,7 @@ mgt_sigchld(const struct ev *e, int what)
 /*--------------------------------------------------------------------*/
 
 static int
-mgt_sigint(const struct ev *e, int what)
+mgt_sigint(const struct vev *e, int what)
 {
 
        (void)e;
@@ -465,12 +465,12 @@ void
 mgt_run(int dflag, const char *T_arg)
 {
        struct sigaction sac;
-       struct ev *e;
+       struct vev *e;
        int i;
 
        mgt_pid = getpid();
 
-       mgt_evb = ev_new_base();
+       mgt_evb = vev_new_base();
        XXXAN(mgt_evb);
 
        if (dflag)
@@ -479,27 +479,27 @@ mgt_run(int dflag, const char *T_arg)
        if (T_arg)
                mgt_cli_telnet(dflag, T_arg);
 
-       e = ev_new();
+       e = vev_new();
        XXXAN(e);
        e->sig = SIGTERM;
        e->callback = mgt_sigint;
        e->name = "mgt_sigterm";
-       AZ(ev_add(mgt_evb, e));
+       AZ(vev_add(mgt_evb, e));
 
-       e = ev_new();
+       e = vev_new();
        XXXAN(e);
        e->sig = SIGINT;
        e->callback = mgt_sigint;
        e->name = "mgt_sigint";
-       AZ(ev_add(mgt_evb, e));
+       AZ(vev_add(mgt_evb, e));
 
-       e = ev_new();
+       e = vev_new();
        XXXAN(e);
        e->sig = SIGCHLD;
        e->sig_flags = SA_NOCLDSTOP;
        e->callback = mgt_sigchld;
        e->name = "mgt_sigchild";
-       AZ(ev_add(mgt_evb, e));
+       AZ(vev_add(mgt_evb, e));
 
        setproctitle("Varnish-Mgr %s", heritage.name);
 
@@ -518,9 +518,9 @@ mgt_run(int dflag, const char *T_arg)
                fprintf(stderr,
                    "Debugging mode, enter \"start\" to start child\n");
 
-       i = ev_schedule(mgt_evb);
+       i = vev_schedule(mgt_evb);
        if (i != 0)
-               REPORT(LOG_ERR, "ev_schedule() = %d", i);
+               REPORT(LOG_ERR, "vev_schedule() = %d", i);
 
        REPORT0(LOG_ERR, "manager dies");
        exit(2);
index f369ce1d790d1194020ec8aa0dddf8376ce1f9f9..b2a835997e41b2bd53aeca07aa68e10171e11903 100644 (file)
@@ -56,7 +56,7 @@
 #include "heritage.h"
 #include "mgt.h"
 #include "mgt_cli.h"
-#include "mgt_event.h"
+#include "vev.h"
 #include "shmlog.h"
 
 #include "vlu.h"
@@ -66,7 +66,7 @@ static int            cli_i = -1, cli_o = -1;
 
 struct telnet {
        int                     fd;
-       struct ev               *ev;
+       struct vev              *ev;
        VTAILQ_ENTRY(telnet)    list;
 };
 
@@ -221,7 +221,7 @@ mgt_cli_stop_child(void)
 struct cli_port {
        unsigned                magic;
 #define CLI_PORT_MAGIC         0x5791079f
-       struct ev               *ev;
+       struct vev              *ev;
        int                     fdi;
        int                     fdo;
        int                     verbose;
@@ -335,7 +335,7 @@ mgt_cli_close(struct cli_port *cp)
  */
 
 static int
-mgt_cli_callback(const struct ev *e, int what)
+mgt_cli_callback(const struct vev *e, int what)
 {
        struct cli_port *cp;
 
@@ -378,7 +378,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident)
        cp->ev->fd_flags = EV_RD;
        cp->ev->callback = mgt_cli_callback;
        cp->ev->priv = cp;
-       AZ(ev_add(mgt_evb, cp->ev));
+       AZ(vev_add(mgt_evb, cp->ev));
 }
 
 /*--------------------------------------------------------------------*/
@@ -424,7 +424,7 @@ telnet_new(int fd)
 }
 
 static int
-telnet_accept(const struct ev *ev, int what)
+telnet_accept(const struct vev *ev, int what)
 {
        struct sockaddr_storage addr;
        socklen_t addrlen;
@@ -476,12 +476,12 @@ mgt_cli_telnet(int dflag, const char *T_arg)
                sock = VSS_listen(ta[i], 10);
                assert(sock >= 0);
                tn = telnet_new(sock);
-               tn->ev = ev_new();
+               tn->ev = vev_new();
                XXXAN(tn->ev);
                tn->ev->fd = sock;
                tn->ev->fd_flags = POLLIN;
                tn->ev->callback = telnet_accept;
-               AZ(ev_add(mgt_evb, tn->ev));
+               AZ(vev_add(mgt_evb, tn->ev));
                free(ta[i]);
                ta[i] = NULL;
        }
diff --git a/varnish-cache/bin/varnishd/mgt_event.c b/varnish-cache/bin/varnishd/mgt_event.c
deleted file mode 100644 (file)
index b935231..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <errno.h>
-#include <poll.h>
-#include <time.h>
-#include <signal.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-
-#include "mgt.h"
-#include "mgt_event.h"
-#include "miniobj.h"
-#include "binary_heap.h"
-
-#undef DEBUG_EVENTS
-
-/* INFTIM indicates an infinite timeout for poll(2) */
-#ifndef INFTIM
-#define INFTIM -1
-#endif
-
-struct evsig {
-       struct evbase           *evb;
-       struct ev               *ev;
-       struct sigaction        sigact;
-       unsigned char           happened;
-};
-
-static struct evsig            *ev_sigs;
-static int                     ev_nsig;
-
-struct evbase {
-       unsigned                magic;
-#define EVBASE_MAGIC           0x0cfd976f
-       VTAILQ_HEAD(,ev)                events;
-       struct pollfd           *pfd;
-       unsigned                npfd;
-       unsigned                lpfd;
-       struct binheap          *binheap;
-       unsigned char           compact_pfd;
-       unsigned char           disturbed;
-       unsigned                psig;
-       pthread_t               thread;
-#ifdef DEBUG_EVENTS
-       FILE                    *debug;
-#endif
-};
-
-/*--------------------------------------------------------------------*/
-
-#ifdef DEBUG_EVENTS
-#define DBG(evb, ...) do {                             \
-       if ((evb)->debug != NULL)                       \
-               fprintf((evb)->debug, __VA_ARGS__);     \
-       } while (0);
-#else
-#define DBG(evb, ...)  /* ... */
-#endif
-
-/*--------------------------------------------------------------------*/
-
-static void
-ev_bh_update(void *priv, void *a, unsigned u)
-{
-       struct evbase *evb;
-       struct ev *e;
-
-       CAST_OBJ_NOTNULL(evb, priv, EVBASE_MAGIC);
-       CAST_OBJ_NOTNULL(e, a, EV_MAGIC);
-       e->__binheap_idx = u;
-}
-
-static int
-ev_bh_cmp(void *priv, void *a, void *b)
-{
-       struct evbase *evb;
-       struct ev *ea, *eb;
-
-       CAST_OBJ_NOTNULL(evb, priv, EVBASE_MAGIC);
-       CAST_OBJ_NOTNULL(ea, a, EV_MAGIC);
-       CAST_OBJ_NOTNULL(eb, b, EV_MAGIC);
-       return (ea->__when < eb->__when);
-}
-
-/*--------------------------------------------------------------------*/
-
-static int
-ev_get_pfd(struct evbase *evb)
-{
-       unsigned u;
-       void *p;
-
-       if (evb->lpfd + 1 < evb->npfd)
-               return (0);
-
-       if (evb->npfd < 8)
-               u = 8;
-       else if (evb->npfd > 256)
-               u = evb->npfd + 256;
-       else
-               u = evb->npfd * 2;
-       p = realloc(evb->pfd, sizeof *evb->pfd * u);
-       if (p == NULL)
-               return (1);
-       evb->npfd = u;
-       evb->pfd = p;
-       return (0);
-}
-
-/*--------------------------------------------------------------------*/
-
-static int
-ev_get_sig(int sig)
-{
-       struct evsig *os;
-
-       if (sig < ev_nsig)
-               return (0);
-
-       os = calloc(sizeof *os, (sig + 1));
-       if (os == NULL)
-               return (ENOMEM);
-
-       memcpy(os, ev_sigs, ev_nsig * sizeof *os);
-
-       free(ev_sigs);
-       ev_sigs = os;
-       ev_nsig = sig + 1;
-
-       return (0);
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-ev_sighandler(int sig)
-{
-       struct evsig *es;
-
-       assert(sig < ev_nsig);
-       assert(ev_sigs != NULL);
-       es = &ev_sigs[sig];
-       if (!es->happened)
-               es->evb->psig++;
-       es->happened = 1;
-}
-
-/*--------------------------------------------------------------------*/
-
-struct evbase *
-ev_new_base(void)
-{
-       struct evbase *evb;
-
-       evb = calloc(sizeof *evb, 1);
-       if (evb == NULL)
-               return (evb);
-       if (ev_get_pfd(evb)) {
-               free(evb);
-               return (NULL);
-       }
-       evb->magic = EVBASE_MAGIC;
-       VTAILQ_INIT(&evb->events);
-       evb->binheap = binheap_new(evb, ev_bh_cmp, ev_bh_update);
-       evb->thread = pthread_self();
-#ifdef DEBUG_EVENTS
-       evb->debug = fopen("/tmp/_.events", "w");
-       AN(evb->debug);
-       setbuf(evb->debug, NULL);
-       DBG(evb, "\n\nStart debugging\n");
-#endif
-       return (evb);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-ev_destroy_base(struct evbase *evb)
-{
-       CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
-       assert(evb->thread == pthread_self());
-       evb->magic = 0;
-       free(evb);
-}
-
-/*--------------------------------------------------------------------*/
-
-struct ev *
-ev_new(void)
-{
-       struct ev *e;
-
-       e = calloc(sizeof *e, 1);
-       if (e != NULL) {
-               e->fd = -1;
-       }
-       return (e);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-ev_add(struct evbase *evb, struct ev *e)
-{
-       struct evsig *es;
-
-       CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
-       assert(e->magic != EV_MAGIC);
-       assert(e->callback != NULL);
-       assert(e->sig >= 0);
-       assert(e->timeout >= 0.0);
-       assert(e->fd < 0 || e->fd_flags);
-       assert(evb->thread == pthread_self());
-       DBG(evb, "ev_add(%p) fd = %d\n", e, e->fd);
-
-       if (e->sig > 0 && ev_get_sig(e->sig))
-               return (ENOMEM);
-
-       if (e->fd >= 0 && ev_get_pfd(evb))
-               return (ENOMEM);
-
-       if (e->sig > 0) {
-               es = &ev_sigs[e->sig];
-               if (es->ev != NULL)
-                       return (EBUSY);
-               assert(es->happened == 0);
-               es->ev = e;
-               es->evb = evb;
-               es->sigact.sa_flags = e->sig_flags;
-               es->sigact.sa_handler = ev_sighandler;
-       } else {
-               es = NULL;
-       }
-
-       if (e->fd >= 0) {
-               assert(evb->lpfd < evb->npfd);
-               evb->pfd[evb->lpfd].fd = e->fd;
-               evb->pfd[evb->lpfd].events =
-                   e->fd_flags & (EV_RD|EV_WR|EV_ERR|EV_HUP);
-               e->__poll_idx = evb->lpfd;
-               evb->lpfd++;
-               DBG(evb, "... pidx = %d lpfd = %d\n",
-                   e->__poll_idx, evb->lpfd);
-       } else
-               e->__poll_idx = -1;
-
-       e->magic = EV_MAGIC;    /* before binheap_insert() */
-
-       if (e->timeout != 0.0) {
-               e->__when += TIM_mono() + e->timeout;
-               binheap_insert(evb->binheap, e);
-               assert(e->__binheap_idx > 0);
-               DBG(evb, "... bidx = %d\n", e->__binheap_idx);
-       } else {
-               e->__when = 0.0;
-               e->__binheap_idx = 0;
-       }
-
-       e->__evb = evb;
-       e->__privflags = 0;
-       if (e->fd < 0)
-               VTAILQ_INSERT_TAIL(&evb->events, e, __list);
-       else
-               VTAILQ_INSERT_HEAD(&evb->events, e, __list);
-
-       if (e->sig > 0) {
-               assert(es != NULL);
-               assert(sigaction(e->sig, &es->sigact, NULL) == 0);
-       }
-
-       return (0);
-}
-
-/*--------------------------------------------------------------------*/
-
-void
-ev_del(struct evbase *evb, struct ev *e)
-{
-       struct evsig *es;
-
-       CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
-       CHECK_OBJ_NOTNULL(e, EV_MAGIC);
-       DBG(evb, "ev_del(%p) fd = %d\n", e, e->fd);
-       assert(evb == e->__evb);
-       assert(evb->thread == pthread_self());
-
-       if (e->__binheap_idx != 0)
-               binheap_delete(evb->binheap, e->__binheap_idx);
-       assert(e->__binheap_idx == 0);
-
-       if (e->fd >= 0) {
-               DBG(evb, "... pidx = %d\n", e->__poll_idx);
-               evb->pfd[e->__poll_idx].fd = -1;
-               if (e->__poll_idx == evb->lpfd - 1)
-                       evb->lpfd--;
-               else
-                       evb->compact_pfd++;
-               e->fd = -1;
-               DBG(evb, "... lpfd = %d\n", evb->lpfd);
-       }
-
-       if (e->sig > 0) {
-               assert(e->sig < ev_nsig);
-               es = &ev_sigs[e->sig];
-               assert(es->ev == e);
-               es->ev = NULL;
-               es->evb = NULL;
-               es->sigact.sa_flags = e->sig_flags;
-               es->sigact.sa_handler = SIG_DFL;
-               assert(sigaction(e->sig, &es->sigact, NULL) == 0);
-               es->happened = 0;
-       }
-
-       VTAILQ_REMOVE(&evb->events, e, __list);
-
-       e->magic = 0;
-       e->__evb = NULL;
-
-       evb->disturbed = 1;
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-ev_schedule(struct evbase *evb)
-{
-       int i;
-
-       CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
-       assert(evb->thread == pthread_self());
-       do
-               i = ev_schedule_one(evb);
-       while (i == 1);
-       return (i);
-}
-
-/*--------------------------------------------------------------------*/
-
-static void
-ev_compact_pfd(struct evbase *evb)
-{
-       unsigned u;
-       struct pollfd *p;
-       struct ev *ep;
-       int lfd;
-
-       DBG(evb, "compact_pfd() lpfd = %d\n", evb->lpfd);
-       p = evb->pfd;
-       for (u = 0; u < evb->lpfd; u++, p++) {
-               DBG(evb, "...[%d] fd = %d\n", u, p->fd);
-               if (p->fd >= 0)
-                       continue;
-               if (u == evb->lpfd - 1)
-                       break;
-               lfd = evb->pfd[evb->lpfd - 1].fd;
-               VTAILQ_FOREACH(ep, &evb->events, __list)
-                       if (ep->fd == lfd)
-                               break;
-               AN(ep);
-               DBG(evb, "...[%d] move %p pidx %d\n", u, ep, ep->__poll_idx);
-               *p = evb->pfd[--evb->lpfd];
-               ep->__poll_idx = u;
-       }
-       evb->lpfd = u;
-       evb->compact_pfd = 0;
-       DBG(evb, "... lpfd = %d\n", evb->lpfd);
-}
-
-/*--------------------------------------------------------------------*/
-
-static int
-ev_sched_timeout(struct evbase *evb, struct ev *e, double t)
-{
-       int i;
-
-
-       i = e->callback(e, 0);
-       if (i) {
-               ev_del(evb, e);
-               free(e);
-       } else {
-               e->__when = t + e->timeout;
-               binheap_delete(evb->binheap, e->__binheap_idx);
-               binheap_insert(evb->binheap, e);
-       }
-       return (1);
-}
-
-static int
-ev_sched_signal(struct evbase *evb)
-{
-       int i, j;
-       struct evsig *es;
-       struct ev *e;
-
-       es = ev_sigs;
-       for (j = 0; j < ev_nsig; j++, es++) {
-               if (!es->happened || es->evb != evb)
-                       continue;
-               evb->psig--;
-               es->happened = 0;
-               e = es->ev;
-               assert(e != NULL);
-               i = e->callback(e, EV_SIG);
-               if (i) {
-                       ev_del(evb, e);
-                       free(e);
-               }
-       }
-       return (1);
-}
-
-int
-ev_schedule_one(struct evbase *evb)
-{
-       double t;
-       struct ev *e, *e2, *e3;
-       int i, j, tmo;
-       struct pollfd *pfd;
-
-       CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC);
-       assert(evb->thread == pthread_self());
-       e = binheap_root(evb->binheap);
-       if (e != NULL) {
-               CHECK_OBJ_NOTNULL(e, EV_MAGIC);
-               assert(e->__binheap_idx == 1);
-               t = TIM_mono();
-               if (e->__when <= t)
-                       return (ev_sched_timeout(evb, e, t));
-               tmo = (int)((e->__when - t) * 1e3);
-               if (tmo == 0)
-                       tmo = 1;
-       } else
-               tmo = INFTIM;
-
-       if (evb->compact_pfd)
-               ev_compact_pfd(evb);
-
-       if (tmo == INFTIM && evb->lpfd == 0)
-               return (0);
-
-       if (evb->psig)
-               return (ev_sched_signal(evb));
-       assert(evb->lpfd < evb->npfd);
-       i = poll(evb->pfd, evb->lpfd, tmo);
-       if(i == -1 && errno == EINTR)
-               return (ev_sched_signal(evb));
-       if (i == 0) {
-               assert(e != NULL);
-               t = TIM_mono();
-               if (e->__when <= t)
-                       return (ev_sched_timeout(evb, e, t));
-       }
-       evb->disturbed = 0;
-       VTAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) {
-               if (i == 0)
-                       break;
-               if (e->fd < 0)
-                       continue;
-               assert(e->__poll_idx < evb->lpfd);
-               pfd = &evb->pfd[e->__poll_idx];
-               assert(pfd->fd == e->fd);
-               if (!pfd->revents)
-                       continue;
-               DBG(evb, "callback(%p) fd = %d what = 0x%x pidx = %d\n",
-                   e, e->fd, pfd->revents, e->__poll_idx);
-               j = e->callback(e, pfd->revents);
-               i--;
-               if (evb->disturbed) {
-                       VTAILQ_FOREACH(e3, &evb->events, __list) {
-                               if (e3 == e) {
-                                       e3 = VTAILQ_NEXT(e, __list);
-                                       break;
-                               } else if (e3 == e2)
-                                       break;
-                       }
-                       e2 = e3;
-                       evb->disturbed = 0;
-               }
-               if (j) {
-                       ev_del(evb, e);
-                       evb->disturbed = 0;
-                       free(e);
-               }
-       }
-       assert(i == 0);
-       return (1);
-}
diff --git a/varnish-cache/bin/varnishd/mgt_event.h b/varnish-cache/bin/varnishd/mgt_event.h
deleted file mode 100644 (file)
index b089d06..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2008 Linpro AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $Id$
- */
-
-#include <poll.h>
-
-#include "vqueue.h"
-
-struct ev;
-struct evbase;
-
-typedef int ev_cb_f(const struct ev *, int what);
-
-struct ev {
-       unsigned        magic;
-#define EV_MAGIC       0x15c8134b
-
-       /* pub */
-       const char      *name;
-       int             fd;
-       unsigned        fd_flags;
-#define                EV_RD   POLLIN
-#define                EV_WR   POLLOUT
-#define                EV_ERR  POLLERR
-#define                EV_HUP  POLLHUP
-#define                EV_GONE POLLNVAL
-#define                EV_SIG  -1
-       int             sig;
-       unsigned        sig_flags;
-       double          timeout;
-       ev_cb_f         *callback;
-       void            *priv;
-
-       /* priv */
-       double          __when;
-       VTAILQ_ENTRY(ev)        __list;
-       unsigned        __binheap_idx;
-       unsigned        __privflags;
-       struct evbase   *__evb;
-       int             __poll_idx;
-};
-
-struct evbase;
-
-struct evbase *ev_new_base(void);
-void ev_destroy_base(struct evbase *evb);
-
-struct ev *ev_new(void);
-
-int ev_add(struct evbase *evb, struct ev *e);
-void ev_del(struct evbase *evb, struct ev *e);
-
-int ev_schedule_one(struct evbase *evb);
-int ev_schedule(struct evbase *evb);