From 5307391aa9ef1188cc872aede5bdbf9e977fb75f Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Fri, 5 Sep 2014 10:23:50 +0500 Subject: The sockaddr_storage returned by accept(2) belongs to session and not the listener. Move it to a place where it belongs: struct session. --- pop3d.h | 6 +++--- pop3e.c | 3 +-- session.c | 7 ++++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pop3d.h b/pop3d.h index 72f50e5..7e3b47f 100644 --- a/pop3d.h +++ b/pop3d.h @@ -114,7 +114,6 @@ struct auth_req { }; struct listener { - struct sockaddr_storage ss; struct event ev; struct event pause; int flags; @@ -129,14 +128,15 @@ enum state { struct session { SPLAY_ENTRY(session) entry; - struct imsgev *iev_maildrop; struct iobuf iobuf; struct io io; + struct sockaddr_storage ss; char user[ARGLEN]; char pass[ARGLEN]; size_t m_sz; size_t nmsgs; struct listener *l; + struct imsgev *iev_maildrop; uint32_t id; int flags; enum state state; @@ -146,7 +146,7 @@ struct session { void pop3_main(int [2], struct passwd *); /* session.c */ -void session_init(struct listener *, int); +void session_init(struct listener *, int, const struct sockaddr_storage *); void session_close(struct session *, int); void session_reply(struct session *, char *, ...); void session_set_state(struct session *, enum state); diff --git a/pop3e.c b/pop3e.c index 728df72..1bd8635 100644 --- a/pop3e.c +++ b/pop3e.c @@ -176,8 +176,7 @@ pop3_accept(int fd, short events, void *arg) } set_nonblocking(s); - l->ss = ss; - session_init(l, s); + session_init(l, s, &ss); } static void diff --git a/session.c b/session.c index 5401e0c..0da444a 100644 --- a/session.c +++ b/session.c @@ -97,7 +97,7 @@ struct session_tree sessions; static int _pop3_debug = 0; void -session_init(struct listener *l, int fd) +session_init(struct listener *l, int fd, const struct sockaddr_storage *ss) { struct session *s; void *ssl; @@ -105,6 +105,7 @@ session_init(struct listener *l, int fd) s = xcalloc(1, sizeof(*s), "session_init"); s->l = l; + memmove(&s->ss, ss, sizeof(*ss)); if (iobuf_init(&s->iobuf, 0, 0) == -1) fatal("iobuf_init"); @@ -120,7 +121,7 @@ session_init(struct listener *l, int fd) return; } - log_connect(s->id, &l->ss, l->ss.ss_len); + log_connect(s->id, &s->ss, s->ss.ss_len); SPLAY_INSERT(session_tree, &sessions, s); session_reply(s, "%s", "+OK pop3d ready"); io_set_write(&s->io); @@ -188,7 +189,7 @@ session_io(struct io *io, int evt) case IO_TLSREADY: /* greet only for pop3s, STLS already greeted */ if (s->flags & POP3S) { - log_connect(s->id, &s->l->ss, s->l->ss.ss_len); + log_connect(s->id, &s->ss, s->ss.ss_len); session_reply(s, "%s", "+OK pop3 ready"); io_set_write(&s->io); } -- cgit v1.2.3