diff options
author | Sunil Nimmagadda <sunil@nimmagadda.net> | 2014-09-05 10:23:50 +0500 |
---|---|---|
committer | Sunil Nimmagadda <sunil@nimmagadda.net> | 2014-09-05 10:23:50 +0500 |
commit | 5307391aa9ef1188cc872aede5bdbf9e977fb75f (patch) | |
tree | 5de905ba946c54107ca565a78c15bae94fa76668 | |
parent | 3b17edbbcaaa631c631453276c58bdc9a8773f58 (diff) |
The sockaddr_storage returned by accept(2) belongs to session and
not the listener. Move it to a place where it belongs: struct
session.
-rw-r--r-- | pop3d.h | 6 | ||||
-rw-r--r-- | pop3e.c | 3 | ||||
-rw-r--r-- | session.c | 7 |
3 files changed, 8 insertions, 8 deletions
@@ -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); @@ -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 @@ -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); } |