summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/control.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2011-05-01 12:57:12 +0000
committerEric Faurot <eric@cvs.openbsd.org>2011-05-01 12:57:12 +0000
commitc451ba908723902ef2bf2ef658ed29e304a28fe1 (patch)
treefde86e74ac869a4d88d3612616972d38e0aa5861 /usr.sbin/smtpd/control.c
parenta98e9bb7b03360436119edd88230330b78dac64f (diff)
the smtpd env is meant to be global, so do not pass it all around.
discussed with and ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r--usr.sbin/smtpd/control.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c
index 8134aa0ce00..28800a90f64 100644
--- a/usr.sbin/smtpd/control.c
+++ b/usr.sbin/smtpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.57 2011/04/13 20:53:18 gilles Exp $ */
+/* $OpenBSD: control.c,v 1.58 2011/05/01 12:57:11 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -47,21 +47,21 @@ struct {
int fd;
} control_state;
-void control_imsg(struct smtpd *, struct imsgev *, struct imsg *);
+void control_imsg(struct imsgev *, struct imsg *);
__dead void control_shutdown(void);
int control_init(void);
-void control_listen(struct smtpd *);
+void control_listen(void);
void control_cleanup(void);
void control_accept(int, short, void *);
struct ctl_conn *control_connbyfd(int);
-void control_close(struct smtpd *, int);
+void control_close(int);
void control_sig_handler(int, short, void *);
void control_dispatch_ext(int, short, void *);
struct ctl_connlist ctl_conns;
void
-control_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg)
+control_imsg(struct imsgev *iev, struct imsg *imsg)
{
struct ctl_conn *c;
struct reload *reload;
@@ -111,7 +111,7 @@ control_sig_handler(int sig, short event, void *p)
pid_t
-control(struct smtpd *env)
+control(void)
{
struct sockaddr_un sun;
int fd;
@@ -136,7 +136,7 @@ control(struct smtpd *env)
return (pid);
}
- purge_config(env, PURGE_EVERYTHING);
+ purge_config(PURGE_EVERYTHING);
pw = env->sc_pw;
@@ -187,8 +187,8 @@ control(struct smtpd *env)
imsg_callback = control_imsg;
event_init();
- signal_set(&ev_sigint, SIGINT, control_sig_handler, env);
- signal_set(&ev_sigterm, SIGTERM, control_sig_handler, env);
+ signal_set(&ev_sigint, SIGINT, control_sig_handler, NULL);
+ signal_set(&ev_sigterm, SIGTERM, control_sig_handler, NULL);
signal_add(&ev_sigint, NULL);
signal_add(&ev_sigterm, NULL);
signal(SIGPIPE, SIG_IGN);
@@ -196,9 +196,9 @@ control(struct smtpd *env)
TAILQ_INIT(&ctl_conns);
- config_pipes(env, peers, nitems(peers));
- config_peers(env, peers, nitems(peers));
- control_listen(env);
+ config_pipes(peers, nitems(peers));
+ config_peers(peers, nitems(peers));
+ control_listen();
if (event_dispatch() < 0)
fatal("event_dispatch");
@@ -215,7 +215,7 @@ control_shutdown(void)
}
void
-control_listen(struct smtpd *env)
+control_listen(void)
{
int avail = availdesc();
@@ -224,7 +224,7 @@ control_listen(struct smtpd *env)
avail--;
event_set(&control_state.ev, control_state.fd, EV_READ|EV_PERSIST,
- control_accept, env);
+ control_accept, NULL);
event_add(&control_state.ev, NULL);
/* guarantee 2 fds to each accepted client */
@@ -246,7 +246,6 @@ control_accept(int listenfd, short event, void *arg)
socklen_t len;
struct sockaddr_un sun;
struct ctl_conn *c;
- struct smtpd *env = arg;
len = sizeof(sun);
if ((connfd = accept(listenfd, (struct sockaddr *)&sun, &len)) == -1) {
@@ -262,9 +261,8 @@ control_accept(int listenfd, short event, void *arg)
imsg_init(&c->iev.ibuf, connfd);
c->iev.handler = control_dispatch_ext;
c->iev.events = EV_READ;
- c->iev.data = env;
event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events,
- c->iev.handler, env);
+ c->iev.handler, NULL);
event_add(&c->iev.ev, NULL);
TAILQ_INSERT_TAIL(&ctl_conns, c, entry);
@@ -292,7 +290,7 @@ control_connbyfd(int fd)
}
void
-control_close(struct smtpd *env, int fd)
+control_close(int fd)
{
struct ctl_conn *c;
@@ -320,7 +318,6 @@ void
control_dispatch_ext(int fd, short event, void *arg)
{
struct ctl_conn *c;
- struct smtpd *env = arg;
struct imsg imsg;
int n;
uid_t euid;
@@ -336,21 +333,21 @@ control_dispatch_ext(int fd, short event, void *arg)
if (event & EV_READ) {
if ((n = imsg_read(&c->iev.ibuf)) == -1 || n == 0) {
- control_close(env, fd);
+ control_close(fd);
return;
}
}
if (event & EV_WRITE) {
if (msgbuf_write(&c->iev.ibuf.w) < 0) {
- control_close(env, fd);
+ control_close(fd);
return;
}
}
for (;;) {
if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) {
- control_close(env, fd);
+ control_close(fd);
return;
}