summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/mta_session.c14
-rw-r--r--usr.sbin/smtpd/queue.c25
-rw-r--r--usr.sbin/smtpd/smtpd.h9
3 files changed, 17 insertions, 31 deletions
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index c29ede6dc52..7e8e20e89ed 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.9 2012/08/18 15:45:12 eric Exp $ */
+/* $OpenBSD: mta_session.c,v 1.10 2012/08/18 20:52:36 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -157,7 +157,7 @@ mta_session(struct mta_route *route)
void
mta_session_imsg(struct imsgev *iev, struct imsg *imsg)
{
- struct mta_batch *batch;
+ uint64_t batch_id;
struct mta_session *s;
struct mta_host *host;
struct secret *secret;
@@ -168,10 +168,10 @@ mta_session_imsg(struct imsgev *iev, struct imsg *imsg)
switch(imsg->hdr.type) {
case IMSG_QUEUE_MESSAGE_FD:
- batch = imsg->data;
+ batch_id = *(uint64_t*)(imsg->data);
if (imsg->fd == -1)
fatalx("mta: cannot obtain msgfd");
- s = tree_xget(&sessions, batch->id);
+ s = tree_xget(&sessions, batch_id);
s->datafp = fdopen(imsg->fd, "r");
if (s->datafp == NULL)
fatal("mta: fdopen");
@@ -257,7 +257,6 @@ mta_enter_state(struct mta_session *s, int newstate)
struct sockaddr *sa;
int max_reuse;
ssize_t q;
- struct mta_batch batch;
again:
oldstate = s->state;
@@ -283,10 +282,9 @@ mta_enter_state(struct mta_session *s, int newstate)
/*
* Obtain message body fd.
*/
- batch.id = s->id;
- batch.msgid = s->task->msgid;
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
- IMSG_QUEUE_MESSAGE_FD, 0, 0, -1, &batch, sizeof(batch));
+ IMSG_QUEUE_MESSAGE_FD, s->task->msgid, 0, -1,
+ &s->id, sizeof(s->id));
break;
case MTA_SECRET:
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index ece47ff5bc2..e6fa7c480f0 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.126 2012/08/18 18:18:23 gilles Exp $ */
+/* $OpenBSD: queue.c,v 1.127 2012/08/18 20:52:36 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -51,7 +51,7 @@ static void queue_sig_handler(int, short, void *);
static void
queue_imsg(struct imsgev *iev, struct imsg *imsg)
{
- static struct mta_batch batch, *mta_batch;
+ static uint64_t batch_id;
struct submit_status ss;
struct envelope *e, evp;
int fd, ret;
@@ -170,21 +170,17 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
return;
case IMSG_BATCH_CREATE:
- bzero(&batch, sizeof batch);
+ batch_id = generate_uid();
+ imsg_compose_event(env->sc_ievs[PROC_MTA],
+ IMSG_BATCH_CREATE, 0, 0, -1,
+ &batch_id, sizeof batch_id);
return;
case IMSG_BATCH_APPEND:
id = *(uint64_t*)(imsg->data);
queue_envelope_load(id, &evp);
- if (!batch.id) {
- batch.id = generate_uid();
- batch.relay = evp.agent.mta.relay;
- imsg_compose_event(env->sc_ievs[PROC_MTA],
- IMSG_BATCH_CREATE, 0, 0, -1,
- &batch, sizeof batch);
- }
evp.lasttry = time(NULL);
- evp.batch_id = batch.id;
+ evp.batch_id = batch_id;
imsg_compose_event(env->sc_ievs[PROC_MTA],
IMSG_BATCH_APPEND, 0, 0, -1, &evp, sizeof evp);
return;
@@ -192,7 +188,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
case IMSG_BATCH_CLOSE:
imsg_compose_event(env->sc_ievs[PROC_MTA],
IMSG_BATCH_CLOSE, 0, 0, -1,
- &batch.id, sizeof batch.id);
+ &batch_id, sizeof batch_id);
return;
}
}
@@ -200,10 +196,9 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
if (iev->proc == PROC_MTA || iev->proc == PROC_MDA) {
switch (imsg->hdr.type) {
case IMSG_QUEUE_MESSAGE_FD:
- mta_batch = imsg->data;
- fd = queue_message_fd_r(mta_batch->msgid);
+ fd = queue_message_fd_r(imsg->hdr.peerid);
imsg_compose_event(iev, IMSG_QUEUE_MESSAGE_FD, 0, 0,
- fd, mta_batch, sizeof *mta_batch);
+ fd, imsg->data, imsg->hdr.len - sizeof imsg->hdr);
return;
case IMSG_QUEUE_DELIVERY_OK:
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 3feb220ecdb..9faf67c2360 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.322 2012/08/18 18:18:23 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.323 2012/08/18 20:52:36 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -765,13 +765,6 @@ struct mta_task {
struct mta_session *session;
};
-struct mta_batch {
- u_int64_t id;
- struct relayhost relay;
-
- u_int32_t msgid;
-};
-
/* maps return structures */
struct map_credentials {
char username[MAX_LINE_SIZE];