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. --- session.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'session.c') 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