diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-03-15 18:12:16 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-03-15 18:12:16 +0000 |
commit | cba696bab4080fdc038f23657d90ba4a1ddd1f37 (patch) | |
tree | 93b3a646acd7d81e176d86af8d24827894b3c68f | |
parent | cd4bafa66f0aa791a8c3d018dd0b0d2715ee2f0a (diff) |
save 4 bytes per message by moving the datafp field of struct message to
struct session where it really belongs.
-rw-r--r-- | usr.sbin/smtpd/smtp.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 18 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 5 |
3 files changed, 15 insertions, 14 deletions
diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index 8254b81d09b..bbc9ac54615 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.29 2009/02/23 00:51:32 chl Exp $ */ +/* $OpenBSD: smtp.c,v 1.30 2009/03/15 18:12:15 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -423,8 +423,8 @@ smtp_dispatch_queue(int sig, short event, void *p) s->s_flags &= ~F_EVLOCKED; if (fd != -1) { - s->s_msg.datafp = fdopen(fd, "w"); - if (s->s_msg.datafp == NULL) { + s->datafp = fdopen(fd, "w"); + if (s->datafp == NULL) { /* no need to handle error, it will be * caught in session_pickup() */ diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index ce87ea4763f..4c1ee204c3f 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.61 2009/03/11 09:58:20 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.62 2009/03/15 18:12:15 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -690,7 +690,7 @@ session_pickup(struct session *s, struct submit_status *ss) case S_DATA: if (ss == NULL) fatalx("bad ss at S_DATA"); - if (s->s_msg.datafp == NULL) + if (s->datafp == NULL) goto tempfail; s->s_state = S_DATACONTENT; @@ -812,9 +812,9 @@ session_read_data(struct session *s, char *line, size_t nread) size_t i; if (strcmp(line, ".") == 0) { - if (! safe_fclose(s->s_msg.datafp)) + if (! safe_fclose(s->datafp)) s->s_msg.status |= S_MESSAGE_TEMPFAILURE; - s->s_msg.datafp = NULL; + s->datafp = NULL; if (s->s_msg.status & S_MESSAGE_PERMFAILURE) { session_respond(s, "554 Transaction failed"); @@ -847,8 +847,8 @@ session_read_data(struct session *s, char *line, size_t nread) len = strlen(line); - if (fwrite(line, len, 1, s->s_msg.datafp) != 1 || - fwrite("\n", 1, 1, s->s_msg.datafp) != 1) { + if (fwrite(line, len, 1, s->datafp) != 1 || + fwrite("\n", 1, 1, s->datafp) != 1) { s->s_msg.status |= S_MESSAGE_TEMPFAILURE; return 0; } @@ -907,9 +907,9 @@ session_destroy(struct session *s) void session_cleanup(struct session *s) { - if (s->s_msg.datafp != NULL) { - fclose(s->s_msg.datafp); - s->s_msg.datafp = NULL; + if (s->datafp != NULL) { + fclose(s->datafp); + s->datafp = NULL; } if (s->s_msg.message_id[0] != '\0') { diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index d3d0bcb8ffb..0bfcc2cd34a 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.91 2009/03/12 11:08:26 pea Exp $ */ +/* $OpenBSD: smtpd.h,v 1.92 2009/03/15 18:12:15 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -458,7 +458,6 @@ struct message { enum message_flags flags; enum message_status status; - FILE *datafp; int mboxfd; int messagefd; }; @@ -616,6 +615,8 @@ struct session { struct batch *batch; TAILQ_HEAD(mxhostlist, mxhost) mxhosts; + + FILE *datafp; }; struct smtpd { |