diff options
-rw-r--r-- | usr.sbin/smtpd/mta.c | 4 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta_session.c | 42 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 33 |
3 files changed, 38 insertions, 41 deletions
diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index f1fcd4023c2..500c77a5255 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.132 2012/05/11 12:12:02 eric Exp $ */ +/* $OpenBSD: mta.c,v 1.133 2012/07/29 13:56:24 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -194,8 +194,6 @@ mta(void) config_pipes(peers, nitems(peers)); config_peers(peers, nitems(peers)); - SPLAY_INIT(&env->mta_sessions); - if (event_dispatch() < 0) fatal("event_dispatch"); mta_shutdown(); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index 17e50500b05..46d87d8dfe8 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.4 2012/07/15 17:36:42 gilles Exp $ */ +/* $OpenBSD: mta_session.c,v 1.5 2012/07/29 13:56:24 eric Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -43,6 +43,34 @@ #include "smtpd.h" #include "log.h" +struct mta_relay { + TAILQ_ENTRY(mta_relay) entry; + struct sockaddr_storage sa; + char fqdn[MAXHOSTNAMELEN]; + int used; +}; + +struct mta_session { + SPLAY_ENTRY(mta_session) entry; + u_int64_t id; + enum mta_state state; + char *host; + int port; + int flags; + TAILQ_HEAD(,mta_relay) relays; + char *authmap; + char *secret; + FILE *datafp; + + TAILQ_HEAD(,mta_task) tasks; + + struct envelope *currevp; + struct iobuf iobuf; + struct io io; + int ext; /* extension */ + struct ssl *ssl; +}; + struct mta_task { SPLAY_ENTRY(mta_task) entry; uint64_t id; @@ -54,6 +82,7 @@ struct mta_task { TAILQ_HEAD(,envelope) envelopes; }; +SPLAY_HEAD(mta_session_tree, mta_session); SPLAY_HEAD(mta_task_tree, mta_task); static void mta_io(struct io *, int); @@ -72,13 +101,14 @@ static struct mta_task * mta_task_lookup(uint64_t, int); static struct mta_task * mta_task_create(uint64_t, struct mta_session *); static void mta_task_free(struct mta_task *); -SPLAY_PROTOTYPE(mtatree, mta_session, entry, mta_session_cmp); +SPLAY_PROTOTYPE(mta_session_tree, mta_session, entry, mta_session_cmp); SPLAY_PROTOTYPE(mta_task_tree, mta_task, entry, mta_task_cmp); static const char * mta_strstate(int); #define MTA_HIWAT 65535 +static struct mta_session_tree mta_sessions = SPLAY_INITIALIZER(&mta_sessions); static struct mta_task_tree mta_tasks = SPLAY_INITIALIZER(&mta_tasks); void @@ -148,7 +178,7 @@ mta_session_imsg(struct imsgev *iev, struct imsg *imsg) TAILQ_INIT(&s->relays); TAILQ_INIT(&s->tasks); - SPLAY_INSERT(mtatree, &env->mta_sessions, s); + SPLAY_INSERT(mta_session_tree, &mta_sessions, s); if (mta_task_create(s->id, s) == NULL) fatalx("mta_session_imsg: mta_task_create"); @@ -413,7 +443,7 @@ mta_enter_state(struct mta_session *s, int newstate) IMSG_BATCH_DONE, 0, 0, -1, NULL, 0); /* deallocate resources */ - SPLAY_REMOVE(mtatree, &env->mta_sessions, s); + SPLAY_REMOVE(mta_session_tree, &mta_sessions, s); while ((relay = TAILQ_FIRST(&s->relays))) { TAILQ_REMOVE(&s->relays, relay, entry); free(relay); @@ -897,12 +927,12 @@ mta_session_lookup(u_int64_t id) struct mta_session key, *res; key.id = id; - if ((res = SPLAY_FIND(mtatree, &env->mta_sessions, &key)) == NULL) + if ((res = SPLAY_FIND(mta_session_tree, &mta_sessions, &key)) == NULL) fatalx("mta_session_lookup: session not found"); return (res); } -SPLAY_GENERATE(mtatree, mta_session, entry, mta_session_cmp); +SPLAY_GENERATE(mta_session_tree, mta_session, entry, mta_session_cmp); static struct mta_task * mta_task_create(u_int64_t id, struct mta_session *s) diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index d1aa6834037..ad1cb032946 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.310 2012/07/12 08:51:43 chl Exp $ */ +/* $OpenBSD: smtpd.h,v 1.311 2012/07/29 13:56:24 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -610,7 +610,6 @@ struct smtpd { SPLAY_HEAD(childtree, child) children; SPLAY_HEAD(lkatree, lka_session) lka_sessions; SPLAY_HEAD(mfatree, mfa_session) mfa_sessions; - SPLAY_HEAD(mtatree, mta_session) mta_sessions; LIST_HEAD(mdalist, mda_session) mda_sessions; struct stats *stats; @@ -829,40 +828,10 @@ enum mta_state { #define MTA_USE_CERT 0x20 #define MTA_TLS 0x40 -struct mta_relay { - TAILQ_ENTRY(mta_relay) entry; - struct sockaddr_storage sa; - char fqdn[MAXHOSTNAMELEN]; - int used; -}; - -struct mta_task; - #define MTA_EXT_STARTTLS 0x01 #define MTA_EXT_AUTH 0x02 #define MTA_EXT_PIPELINING 0x04 -struct mta_session { - SPLAY_ENTRY(mta_session) entry; - u_int64_t id; - enum mta_state state; - char *host; - int port; - int flags; - TAILQ_HEAD(,mta_relay) relays; - char *authmap; - char *secret; - FILE *datafp; - - TAILQ_HEAD(,mta_task) tasks; - - struct envelope *currevp; - struct iobuf iobuf; - struct io io; - int ext; /* extension */ - struct ssl *ssl; -}; - struct mta_batch { u_int64_t id; struct relayhost relay; |