diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/control.c | 82 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue.c | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 26 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 30 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 91 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 24 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 17 | ||||
-rw-r--r-- | usr.sbin/smtpd/ssl.c | 16 |
9 files changed, 95 insertions, 225 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 7dbfe9b2492..72598b56e54 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.28 2009/05/20 16:07:26 gilles Exp $ */ +/* $OpenBSD: control.c,v 1.29 2009/05/24 14:22:23 jacekm Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -319,19 +319,12 @@ control_dispatch_ext(int fd, short event, void *arg) imsg_compose(env->sc_ibufs[PROC_SMTP], IMSG_SMTP_ENQUEUE, 0, 0, -1, &fd, sizeof(fd)); break; - case IMSG_STATS: { - struct stats s; - + case IMSG_STATS: if (euid) goto badcred; - - s.fd = fd; - imsg_compose(env->sc_ibufs[PROC_PARENT], IMSG_STATS, 0, 0, -1, &s, sizeof(s)); - imsg_compose(env->sc_ibufs[PROC_QUEUE], IMSG_STATS, 0, 0, -1, &s, sizeof(s)); - imsg_compose(env->sc_ibufs[PROC_RUNNER], IMSG_STATS, 0, 0, -1, &s, sizeof(s)); - imsg_compose(env->sc_ibufs[PROC_SMTP], IMSG_STATS, 0, 0, -1, &s, sizeof(s)); + imsg_compose(&c->ibuf, IMSG_STATS, 0, 0, -1, + env->stats, sizeof(struct stats)); break; - } case IMSG_RUNNER_SCHEDULE: { struct sched *s = imsg.data; @@ -540,22 +533,6 @@ control_dispatch_parent(int sig, short event, void *p) imsg_compose(&c->ibuf, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; } - case IMSG_STATS: { - struct stats *s = imsg.data; - struct ctl_conn *c; - - IMSG_SIZE_CHECK(s); - - if ((c = control_connbyfd(s->fd)) == NULL) { - log_warn("control_dispatch_parent: fd %d not found", s->fd); - return; - } - - imsg_compose(&c->ibuf, IMSG_PARENT_STATS, 0, 0, -1, - &s->u.parent, sizeof(s->u.parent)); - - break; - } default: log_warnx("control_dispatch_parent: got imsg %d", imsg.hdr.type); @@ -694,23 +671,6 @@ control_dispatch_queue(int sig, short event, void *p) break; switch (imsg.hdr.type) { - case IMSG_STATS: { - struct stats *s = imsg.data; - struct ctl_conn *c; - - IMSG_SIZE_CHECK(s); - - if ((c = control_connbyfd(s->fd)) == NULL) { - log_warn("control_dispatch_queue: fd %d not found", s->fd); - imsg_free(&imsg); - return; - } - - imsg_compose(&c->ibuf, IMSG_QUEUE_STATS, 0, 0, -1, - &s->u.queue, sizeof(s->u.queue)); - - break; - } default: log_warnx("control_dispatch_queue: got imsg %d", imsg.hdr.type); @@ -757,23 +717,6 @@ control_dispatch_runner(int sig, short event, void *p) break; switch (imsg.hdr.type) { - case IMSG_STATS: { - struct stats *s = imsg.data; - struct ctl_conn *c; - - IMSG_SIZE_CHECK(s); - - if ((c = control_connbyfd(s->fd)) == NULL) { - log_warn("control_dispatch_runner: fd %d not found", s->fd); - imsg_free(&imsg); - return; - } - - imsg_compose(&c->ibuf, IMSG_RUNNER_STATS, 0, 0, -1, - &s->u.runner, sizeof(s->u.runner)); - - break; - } case IMSG_RUNNER_SCHEDULE: { struct sched *s = imsg.data; struct ctl_conn *c; @@ -838,23 +781,6 @@ control_dispatch_smtp(int sig, short event, void *p) break; switch (imsg.hdr.type) { - case IMSG_STATS: { - struct stats *s = imsg.data; - struct ctl_conn *c; - - IMSG_SIZE_CHECK(s); - - if ((c = control_connbyfd(s->fd)) == NULL) { - log_warn("control_dispatch_queue: fd %d not found", s->fd); - imsg_free(&imsg); - return; - } - - imsg_compose(&c->ibuf, IMSG_SMTP_STATS, 0, 0, -1, - &s->u.smtp, sizeof(s->u.smtp)); - - break; - } case IMSG_SMTP_ENQUEUE: { int *fd = imsg.data; struct ctl_conn *c; diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 64c1e53c362..efd11dbe7f7 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.63 2009/05/19 11:24:24 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.64 2009/05/24 14:22:23 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -56,8 +56,6 @@ int queue_remove_layout_envelope(char *, struct message *); int queue_commit_layout_message(char *, struct message *); int queue_open_layout_messagefile(char *, struct message *); -struct s_queue s_queue; - void queue_sig_handler(int sig, short event, void *p) { @@ -107,15 +105,6 @@ queue_dispatch_control(int sig, short event, void *p) break; switch (imsg.hdr.type) { - case IMSG_STATS: { - struct stats *s = imsg.data; - - IMSG_SIZE_CHECK(s); - - s->u.queue = s_queue; - imsg_compose(ibuf, IMSG_STATS, 0, 0, -1, s, sizeof(*s)); - break; - } default: log_warnx("queue_dispatch_control: got imsg %d", imsg.hdr.type); @@ -214,10 +203,10 @@ queue_dispatch_smtp(int sig, short event, void *p) if (messagep->flags & F_MESSAGE_ENQUEUED) { f = enqueue_commit_message; - counter = &s_queue.inserts_local; + counter = &env->stats->queue.inserts_local; } else { f = queue_commit_incoming_message; - counter = &s_queue.inserts_remote; + counter = &env->stats->queue.inserts_remote; } if (f(messagep)) diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 8394f0a4928..c242f44b82b 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.46 2009/05/19 11:24:24 jacekm Exp $ */ +/* $OpenBSD: runner.c,v 1.47 2009/05/24 14:22:23 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -82,8 +82,6 @@ struct batch *batch_lookup(struct smtpd *, struct message *); int runner_force_envelope_schedule(char *); int runner_force_message_schedule(char *); -struct s_runner s_runner; - void runner_sig_handler(int sig, short event, void *p) { @@ -194,15 +192,6 @@ runner_dispatch_control(int sig, short event, void *p) case IMSG_MTA_RESUME: env->sc_opts &= ~SMTPD_MTA_PAUSED; break; - case IMSG_STATS: { - struct stats *s = imsg.data; - - IMSG_SIZE_CHECK(s); - - s->u.runner = s_runner; - imsg_compose(ibuf, IMSG_STATS, 0, 0, -1, s, sizeof(*s)); - break; - } case IMSG_RUNNER_SCHEDULE: { struct sched *s = imsg.data; @@ -268,7 +257,7 @@ runner_dispatch_queue(int sig, short event, void *p) IMSG_SIZE_CHECK(m); - s_runner.active--; + env->stats->runner.active--; queue_message_update(m); break; } @@ -936,7 +925,7 @@ batch_record(struct smtpd *env, struct message *messagep) } TAILQ_INSERT_TAIL(&batchp->messages, messagep, entry); - s_runner.active++; + env->stats->runner.active++; return batchp; } diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index f9c9bcc5e18..13b9d79b742 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.48 2009/05/20 14:29:44 gilles Exp $ */ +/* $OpenBSD: smtp.c,v 1.49 2009/05/24 14:22:23 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -52,8 +52,6 @@ void smtp_accept(int, short, void *); void session_auth_pickup(struct session *, char *, size_t); struct session *session_lookup(struct smtpd *, u_int64_t); -struct s_session s_smtp; - void smtp_sig_handler(int sig, short event, void *p) { @@ -511,7 +509,8 @@ smtp_dispatch_control(int sig, short event, void *p) bzero(&l, sizeof(l)); l.env = env; - if (s_smtp.sessions_active >= env->sc_maxconn) { + if (env->stats->smtp.sessions_active >= + env->sc_maxconn) { log_warnx("denying local connection, too many" " sessions active"); imsg_compose(ibuf, IMSG_SMTP_ENQUEUE, 0, 0, -1, @@ -541,8 +540,8 @@ smtp_dispatch_control(int sig, short event, void *p) memcpy(&s->s_ss, res->ai_addr, res->ai_addrlen); - s_smtp.sessions++; - s_smtp.sessions_active++; + env->stats->smtp.sessions++; + env->stats->smtp.sessions_active++; strlcpy(s->s_hostname, "localhost", sizeof(s->s_hostname)); @@ -563,15 +562,6 @@ smtp_dispatch_control(int sig, short event, void *p) case IMSG_SMTP_RESUME: smtp_resume(env); break; - case IMSG_STATS: { - struct stats *s; - - s = imsg.data; - IMSG_SIZE_CHECK(s); - s->u.smtp = s_smtp; - imsg_compose(ibuf, IMSG_STATS, 0, 0, -1, s, sizeof(*s)); - break; - } default: log_warnx("smtp_dispatch_control: got imsg %d", imsg.hdr.type); @@ -740,10 +730,10 @@ smtp_accept(int fd, short event, void *p) event_add(&l->ev, NULL); - s_smtp.sessions++; - s_smtp.sessions_active++; + s->s_env->stats->smtp.sessions++; + s->s_env->stats->smtp.sessions_active++; - if (s_smtp.sessions_active == s->s_env->sc_maxconn) + if (s->s_env->stats->smtp.sessions_active == s->s_env->sc_maxconn) event_del(&l->ev); dns_query_ptr(l->env, &s->s_ss, s->s_id); diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 05a2ea99793..7c098468c0d 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.93 2009/05/20 16:12:11 jacekm Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.94 2009/05/24 14:22:24 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -74,8 +74,6 @@ int session_set_path(struct path *, char *); void session_imsg(struct session *, enum smtp_proc_type, enum imsg_type, u_int32_t, pid_t, int, void *, u_int16_t); -extern struct s_session s_smtp; - struct session_cmd { char *name; int (*func)(struct session *, char *); @@ -600,7 +598,7 @@ session_pickup(struct session *s, struct submit_status *ss) if ((ss != NULL && ss->code == 421) || (s->s_msg.status & S_MESSAGE_TEMPFAILURE)) { session_respond(s, "421 Service temporarily unavailable"); - s_smtp.tempfail++; + s->s_env->stats->smtp.tempfail++; s->s_flags |= F_QUIT; return; } @@ -743,7 +741,7 @@ session_read(struct bufferevent *bev, void *p) if (! expect_lines) { session_respond(s, "500 Pipelining unsupported"); - s_smtp.toofast++; + s->s_env->stats->smtp.toofast++; s->s_flags |= F_QUIT; return; } @@ -791,7 +789,7 @@ session_read(struct bufferevent *bev, void *p) tempfail: session_respond(s, "421 Service temporarily unavailable"); - s_smtp.tempfail++; + s->s_env->stats->smtp.tempfail++; s->s_flags |= F_QUIT; } @@ -812,7 +810,7 @@ session_read_data(struct session *s, char *line, size_t nread) } else if (s->s_msg.status & S_MESSAGE_TEMPFAILURE) { session_respond(s, "421 Temporary failure"); s->s_flags |= F_QUIT; - s_smtp.tempfail++; + s->s_env->stats->smtp.tempfail++; } else { session_imsg(s, PROC_QUEUE, IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &s->s_msg, sizeof(s->s_msg)); @@ -907,12 +905,12 @@ session_error(struct bufferevent *bev, short event, void *p) if (event & EVBUFFER_READ) { if (event & EVBUFFER_TIMEOUT) { log_warnx("client %s read timeout", ip); - s_smtp.read_timeout++; + s->s_env->stats->smtp.read_timeout++; } else if (event & EVBUFFER_EOF) - s_smtp.read_eof++; + s->s_env->stats->smtp.read_eof++; else if (event & EVBUFFER_ERROR) { log_warn("client %s read error", ip); - s_smtp.read_error++; + s->s_env->stats->smtp.read_error++; } session_destroy(s); @@ -922,12 +920,12 @@ session_error(struct bufferevent *bev, short event, void *p) if (event & EVBUFFER_WRITE) { if (event & EVBUFFER_TIMEOUT) { log_warnx("client %s write timeout", ip); - s_smtp.write_timeout++; + s->s_env->stats->smtp.write_timeout++; } else if (event & EVBUFFER_EOF) - s_smtp.write_eof++; + s->s_env->stats->smtp.write_eof++; else if (event & EVBUFFER_ERROR) { log_warn("client %s write error", ip); - s_smtp.write_error++; + s->s_env->stats->smtp.write_error++; } if (s->s_flags & F_WRITEONLY) @@ -964,8 +962,8 @@ session_destroy(struct session *s) if (close(s->s_fd) == -1) fatal("session_destroy: close"); - s_smtp.sessions_active--; - if (s_smtp.sessions_active < s->s_env->sc_maxconn && + s->s_env->stats->smtp.sessions_active--; + if (s->s_env->stats->smtp.sessions_active < s->s_env->sc_maxconn && !(s->s_msg.flags & F_MESSAGE_ENQUEUED)) { /* * if our session_destroy occurs because of a configuration @@ -990,7 +988,7 @@ session_readline(struct session *s, size_t *nr) if (line == NULL) { if (EVBUFFER_LENGTH(s->s_bev->input) > SMTP_ANYLINE_MAX) { session_respond(s, "500 Line too long"); - s_smtp.linetoolong++; + s->s_env->stats->smtp.linetoolong++; s->s_flags |= F_QUIT; } return NULL; diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 650792332df..597c9b32e54 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.26 2009/05/20 11:58:06 gilles Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.27 2009/05/24 14:22:24 jacekm Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -260,60 +260,45 @@ show_command_output(struct imsg *imsg) int show_stats_output(struct imsg *imsg) { - static int left = 4; - static struct s_parent s_parent; - static struct s_queue s_queue; - static struct s_runner s_runner; - static struct s_session s_smtp; + struct stats *stats; - switch (imsg->hdr.type) { - case IMSG_PARENT_STATS: - s_parent = *(struct s_parent *)imsg->data; - break; - case IMSG_QUEUE_STATS: - s_queue = *(struct s_queue *)imsg->data; - break; - case IMSG_RUNNER_STATS: - s_runner = *(struct s_runner *)imsg->data; - break; - case IMSG_SMTP_STATS: - s_smtp = *(struct s_session *)imsg->data; - break; - default: + if (imsg->hdr.type != IMSG_STATS) errx(1, "show_stats_output: bad hdr type (%d)", imsg->hdr.type); - } - - left--; - if (left > 0) - return (0); - - printf("parent.uptime=%d\n", time(NULL) - s_parent.start); - - printf("queue.inserts.local=%zd\n", s_queue.inserts_local); - printf("queue.inserts.remote=%zd\n", s_queue.inserts_remote); - - printf("runner.active=%zd\n", s_runner.active); - - printf("smtp.errors.linetoolong=%zd\n", s_smtp.linetoolong); - printf("smtp.errors.read_eof=%zd\n", s_smtp.read_eof); - printf("smtp.errors.read_system=%zd\n", s_smtp.read_error); - printf("smtp.errors.read_timeout=%zd\n", s_smtp.read_timeout); - printf("smtp.errors.tempfail=%zd\n", s_smtp.tempfail); - printf("smtp.errors.toofast=%zd\n", s_smtp.toofast); - printf("smtp.errors.write_eof=%zd\n", s_smtp.write_eof); - printf("smtp.errors.write_system=%zd\n", s_smtp.write_error); - printf("smtp.errors.write_timeout=%zd\n", s_smtp.write_timeout); - - printf("smtp.sessions=%zd\n", s_smtp.sessions); - printf("smtp.sessions.aborted=%zd\n", s_smtp.read_eof + - s_smtp.read_error + s_smtp.write_eof + s_smtp.write_error); - printf("smtp.sessions.active=%zd\n", s_smtp.sessions_active); - printf("smtp.sessions.timeout=%zd\n", s_smtp.read_timeout + - s_smtp.write_timeout); - printf("smtp.sessions.smtps=%zd\n", s_smtp.smtps); - printf("smtp.sessions.smtps.active=%zd\n", s_smtp.smtps_active); - printf("smtp.sessions.starttls=%zd\n", s_smtp.starttls); - printf("smtp.sessions.starttls.active=%zd\n", s_smtp.starttls_active); + + if (IMSG_DATA_SIZE(imsg) != sizeof(*stats)) + errx(1, "show_stats_output: bad data size"); + + stats = imsg->data; + + printf("parent.uptime=%d\n", time(NULL) - stats->parent.start); + + printf("queue.inserts.local=%zd\n", stats->queue.inserts_local); + printf("queue.inserts.remote=%zd\n", stats->queue.inserts_remote); + + printf("runner.active=%zd\n", stats->runner.active); + + printf("smtp.errors.linetoolong=%zd\n", stats->smtp.linetoolong); + printf("smtp.errors.read_eof=%zd\n", stats->smtp.read_eof); + printf("smtp.errors.read_system=%zd\n", stats->smtp.read_error); + printf("smtp.errors.read_timeout=%zd\n", stats->smtp.read_timeout); + printf("smtp.errors.tempfail=%zd\n", stats->smtp.tempfail); + printf("smtp.errors.toofast=%zd\n", stats->smtp.toofast); + printf("smtp.errors.write_eof=%zd\n", stats->smtp.write_eof); + printf("smtp.errors.write_system=%zd\n", stats->smtp.write_error); + printf("smtp.errors.write_timeout=%zd\n", stats->smtp.write_timeout); + + printf("smtp.sessions=%zd\n", stats->smtp.sessions); + printf("smtp.sessions.aborted=%zd\n", stats->smtp.read_eof + + stats->smtp.read_error + stats->smtp.write_eof + + stats->smtp.write_error); + printf("smtp.sessions.active=%zd\n", stats->smtp.sessions_active); + printf("smtp.sessions.timeout=%zd\n", stats->smtp.read_timeout + + stats->smtp.write_timeout); + printf("smtp.sessions.smtps=%zd\n", stats->smtp.smtps); + printf("smtp.sessions.smtps.active=%zd\n", stats->smtp.smtps_active); + printf("smtp.sessions.starttls=%zd\n", stats->smtp.starttls); + printf("smtp.sessions.starttls.active=%zd\n", + stats->smtp.starttls_active); return (1); } diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 0a701fa6f7b..29db0eb3a1b 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.63 2009/05/20 16:07:26 gilles Exp $ */ +/* $OpenBSD: smtpd.c,v 1.64 2009/05/24 14:22:24 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -27,6 +27,7 @@ #include <sys/stat.h> #include <sys/uio.h> #include <sys/resource.h> +#include <sys/mman.h> #include <bsd_auth.h> #include <err.h> @@ -86,8 +87,6 @@ pid_t control_pid = 0; pid_t smtp_pid = 0; pid_t runner_pid = 0; -struct s_parent s_parent; - int __b64_pton(char const *, unsigned char *, size_t); __dead void @@ -663,15 +662,6 @@ parent_dispatch_control(int sig, short event, void *p) imsg_compose(ibuf, IMSG_CONF_RELOAD, 0, 0, -1, r, sizeof(*r)); break; } - case IMSG_STATS: { - struct stats *s = imsg.data; - - IMSG_SIZE_CHECK(s); - - s->u.parent = s_parent; - imsg_compose(ibuf, IMSG_STATS, 0, 0, -1, s, sizeof(*s)); - break; - } default: log_warnx("parent_dispatch_control: got imsg %d", imsg.hdr.type); @@ -863,6 +853,14 @@ main(int argc, char *argv[]) log_info("startup%s", (debug > 1)?" [debug mode]":""); + env.stats = mmap(NULL, sizeof(struct stats), PROT_WRITE|PROT_READ, + MAP_ANON|MAP_SHARED, -1, (off_t)0); + if (env.stats == MAP_FAILED) + fatal("mmap"); + bzero(env.stats, sizeof(struct stats)); + + env.stats->parent.start = time(NULL); + if (getrlimit(RLIMIT_NOFILE, &rl) == -1) fatal("smtpd: failed to get resource limit"); @@ -903,8 +901,6 @@ main(int argc, char *argv[]) SPLAY_INIT(&env.mdaproc_queue); - s_parent.start = time(NULL); - event_init(); signal_set(&ev_sigint, SIGINT, parent_sig_handler, &env); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 11d9e0ac147..d8ff2ca2bf4 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.112 2009/05/20 14:29:44 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.113 2009/05/24 14:22:24 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -670,6 +670,8 @@ struct smtpd { SPLAY_HEAD(batchtree, batch) batch_queue; SPLAY_HEAD(mdaproctree, mdaproc) mdaproc_queue; SPLAY_HEAD(lkatree, lkasession) lka_sessions; + + struct stats *stats; }; struct s_parent { @@ -707,14 +709,11 @@ struct s_session { }; struct stats { - int fd; - union u_stats { - struct s_parent parent; - struct s_queue queue; - struct s_runner runner; - struct s_session smtp; - struct s_session mta; - } u; + struct s_parent parent; + struct s_queue queue; + struct s_runner runner; + struct s_session mta; + struct s_session smtp; }; struct sched { diff --git a/usr.sbin/smtpd/ssl.c b/usr.sbin/smtpd/ssl.c index 1bbdd5c6203..6d7b75a6dfa 100644 --- a/usr.sbin/smtpd/ssl.c +++ b/usr.sbin/smtpd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.15 2009/05/19 22:41:35 gilles Exp $ */ +/* $OpenBSD: ssl.c,v 1.16 2009/05/24 14:22:24 jacekm Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -55,8 +55,6 @@ void ssl_client_init(struct session *); extern void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void *); -extern struct s_session s_smtp; - void ssl_connect(int fd, short event, void *p) { @@ -505,12 +503,12 @@ ssl_session_accept(int fd, short event, void *p) s->s_flags |= F_SECURE; if (s->s_l->flags & F_SMTPS) { - s_smtp.smtps++; - s_smtp.smtps_active++; + s->s_env->stats->smtp.smtps++; + s->s_env->stats->smtp.smtps_active++; } if (s->s_l->flags & F_STARTTLS) { - s_smtp.starttls++; - s_smtp.starttls_active++; + s->s_env->stats->smtp.starttls++; + s->s_env->stats->smtp.starttls_active++; } session_bufferevent_new(s); @@ -602,10 +600,10 @@ ssl_session_destroy(struct session *s) if (s->s_l->flags & F_SMTPS) { if (s->s_flags & F_SECURE) - s_smtp.smtps_active--; + s->s_env->stats->smtp.smtps_active--; } if (s->s_l->flags & F_STARTTLS) { if (s->s_flags & F_SECURE) - s_smtp.starttls_active--; + s->s_env->stats->smtp.starttls_active--; } } |