From 9dfe6e27554c4e9ba33949827433f475758d59f1 Mon Sep 17 00:00:00 2001 From: Jacek Masiulaniec Date: Sat, 12 Dec 2009 14:04:00 +0000 Subject: 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. --- usr.sbin/smtpd/bounce.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'usr.sbin/smtpd/bounce.c') 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 @@ -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 \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); -- cgit v1.2.3