summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/bounce.c
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-12-12 14:04:00 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-12-12 14:04:00 +0000
commit9dfe6e27554c4e9ba33949827433f475758d59f1 (patch)
tree03fdbacb300cbac33848fe257e081297a144c613 /usr.sbin/smtpd/bounce.c
parent32ca805073b05a555e12df3429094a6a0fd4d86d (diff)
When acting as a client do content reads from the disk progressively
as the remote accepts more data instead of doing one big read into the memory in the beginning of session.
Diffstat (limited to 'usr.sbin/smtpd/bounce.c')
-rw-r--r--usr.sbin/smtpd/bounce.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index 52feb25ad5a..a313b8503a5 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.13 2009/12/12 10:33:11 jacekm Exp $ */
+/* $OpenBSD: bounce.c,v 1.14 2009/12/12 14:03:59 jacekm Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -58,10 +58,14 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep)
int msgfd = -1;
char *reason;
+ /* get message content */
+ if ((msgfd = queue_open_message_file(messagep->message_id)) == -1)
+ goto fail;
+
/* init smtp session */
if ((cc = calloc(1, sizeof(*cc))) == NULL)
goto fail;
- cc->pcb = client_init(fd, env->sc_hostname, 1);
+ cc->pcb = client_init(fd, msgfd, env->sc_hostname, 1);
cc->m = *messagep;
client_ssl_optional(cc->pcb);
@@ -77,7 +81,7 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep)
/* create message header */
/* XXX - The Date: header should be added during SMTP pickup. */
- client_data_printf(cc->pcb,
+ client_printf(cc->pcb,
"Subject: Delivery status notification\n"
"From: Mailer Daemon <MAILER-DAEMON@%s>\n"
"To: %s@%s\n"
@@ -100,13 +104,6 @@ bounce_session(struct smtpd *env, int fd, struct message *messagep)
messagep->recipient.user, messagep->recipient.domain,
reason);
- /* append original message */
- if ((msgfd = queue_open_message_file(messagep->message_id)) == -1)
- goto fail;
- client_data_fd(cc->pcb, msgfd);
- close(msgfd);
- msgfd = -1;
-
/* setup event */
session_socket_blockmode(fd, BM_NONBLOCK);
event_set(&cc->ev, fd, EV_WRITE, bounce_event, cc);