Commit c6caca9a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Retire mgt_event.[ch] and use instead the (new) copy of it in libvarnish.



git-svn-id: http://www.varnish-cache.org/svn/trunk@2940 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 1bfaac81
......@@ -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
......
......@@ -49,7 +49,6 @@
#include "shmlog.h"
#include "cache.h"
#include "mgt_event.h"
#include "vrt.h"
#include "cache_backend.h"
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
......
This diff is collapsed.
/*-
* 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);
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