summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/bounce.c
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-08-09 09:48:03 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-08-09 09:48:03 +0000
commit228501da23f4c47dfd29423d4a0ec553fc140549 (patch)
tree11df7046d7866f0ef41dcf2ea8e17c013d42f687 /usr.sbin/smtpd/bounce.c
parentdaeaa7f23c7c4ef46a99aded43a1464ff29377f2 (diff)
Improve the message flows to completely isolate operations on the
queue backend within the queue process. The scheduler sends envelope ids to the queue process which loads the envelope and forward the request to the agent responsible for the delivery. The result is sent by the agent to the queue which updates the storage before notifying the scheduler. Bounces are created and enqueued (from the client side) by the queue process, rather than the scheduler. ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/bounce.c')
-rw-r--r--usr.sbin/smtpd/bounce.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index f31b322ef29..c0248cfb3e7 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.43 2012/08/08 08:50:42 eric Exp $ */
+/* $OpenBSD: bounce.c,v 1.44 2012/08/09 09:48:02 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -60,10 +60,6 @@ struct bounce {
struct io io;
};
-/* XXX remove later */
-void scheduler_envelope_update(struct envelope *);
-void scheduler_envelope_delete(struct envelope *);
-
static void bounce_send(struct bounce *, const char *, ...);
static int bounce_next(struct bounce *);
static void bounce_status(struct bounce *, const char *, ...);
@@ -197,9 +193,10 @@ bounce_next(struct bounce *bounce)
static void
bounce_status(struct bounce *bounce, const char *fmt, ...)
{
- va_list ap;
- char *status;
- int len;
+ va_list ap;
+ char *status;
+ int len, msg;
+ struct envelope *evp;
/* ignore if the envelope has already been updated/deleted */
if (bounce->evp.id == 0)
@@ -210,17 +207,26 @@ bounce_status(struct bounce *bounce, const char *fmt, ...)
fatal("bounce: vasprintf");
va_end(ap);
- if (*status == '2' || *status == '5' || *status == '6') {
- log_debug("#### %s: queue_envelope_delete: %016" PRIx64,
- __func__, bounce->evp.id);
- queue_envelope_delete(&bounce->evp);
- scheduler_envelope_delete(&bounce->evp);
+ if (*status == '2')
+ msg = IMSG_QUEUE_DELIVERY_OK;
+ else if (*status == '5' || *status == '6')
+ msg = IMSG_QUEUE_DELIVERY_PERMFAIL;
+ else
+ msg = IMSG_QUEUE_DELIVERY_TEMPFAIL;
+
+ evp = &bounce->evp;
+ if (msg == IMSG_QUEUE_DELIVERY_TEMPFAIL) {
+ evp->retry++;
+ envelope_set_errormsg(evp, "%s", status);
+ queue_envelope_update(evp);
+ imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0, 0, -1,
+ evp, sizeof *evp);
} else {
- bounce->evp.retry++;
- envelope_set_errormsg(&bounce->evp, "%s", status);
- queue_envelope_update(&bounce->evp);
- scheduler_envelope_update(&bounce->evp);
+ queue_envelope_delete(evp);
+ imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], msg, 0, 0, -1,
+ &evp->id, sizeof evp->id);
}
+
bounce->evp.id = 0;
free(status);
}
@@ -234,9 +240,6 @@ bounce_free(struct bounce *bounce)
iobuf_clear(&bounce->iobuf);
io_clear(&bounce->io);
free(bounce);
-
- stat_decrement(STATS_SCHEDULER);
- stat_decrement(STATS_SCHEDULER_BOUNCES);
}
static void