diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2008-12-27 17:12:40 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2008-12-27 17:12:40 +0000 |
commit | 47a5311facf8181b72c48bcce4a40d912fdd2e99 (patch) | |
tree | 89d2207abb3f186e72f4332b009ad283a3c5c81f /usr.sbin/smtpd/queue.c | |
parent | 29e07dae46b86f909a1983d731d49dcc7048027c (diff) |
Put common handler code in a function; ok chl@ gilles@
Diffstat (limited to 'usr.sbin/smtpd/queue.c')
-rw-r--r-- | usr.sbin/smtpd/queue.c | 106 |
1 files changed, 39 insertions, 67 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index d2447973f28..2c43ddf473a 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.32 2008/12/27 17:03:29 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.33 2008/12/27 17:12:39 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -75,6 +75,7 @@ int queue_process_message(struct smtpd *, char *); void queue_process_envelope(struct smtpd *, char *, char *); int queue_load_envelope(struct message *, char *); void queue_delete_message(char *); +void queue_message_update(struct message *); void batch_send(struct smtpd *, struct batch *, time_t); struct batch *queue_record_batch(struct smtpd *, struct message *); @@ -328,39 +329,7 @@ queue_dispatch_mda(int sig, short event, void *p) switch (imsg.hdr.type) { case IMSG_QUEUE_MESSAGE_UPDATE: { - struct message *messagep; - - messagep = (struct message *)imsg.data; - messagep->batch_id = 0; - messagep->retry++; - - if (messagep->status & S_MESSAGE_TEMPFAILURE) { - messagep->status &= ~S_MESSAGE_TEMPFAILURE; - messagep->flags &= ~F_MESSAGE_PROCESSING; - queue_update_envelope(messagep); - break; - } - - if (messagep->status & S_MESSAGE_PERMFAILURE) { - struct message msave; - - messagep->status &= ~S_MESSAGE_PERMFAILURE; - if ((messagep->type & T_DAEMON_MESSAGE) == 0) { - msave = *messagep; - messagep->id = queue_generate_id(); - messagep->batch_id = 0; - messagep->type |= T_DAEMON_MESSAGE; - messagep->lasttry = 0; - messagep->retry = 0; - queue_record_envelope(messagep); - *messagep = msave; - } - queue_remove_envelope(messagep); - break; - } - - /* no error, remove envelope */ - queue_remove_envelope(messagep); + queue_message_update(imsg.data); break; } @@ -423,39 +392,7 @@ queue_dispatch_mta(int sig, short event, void *p) } case IMSG_QUEUE_MESSAGE_UPDATE: { - struct message *messagep; - - messagep = (struct message *)imsg.data; - messagep->batch_id = 0; - messagep->retry++; - - if (messagep->status & S_MESSAGE_TEMPFAILURE) { - messagep->status &= ~S_MESSAGE_TEMPFAILURE; - messagep->flags &= ~F_MESSAGE_PROCESSING; - queue_update_envelope(messagep); - break; - } - - if (messagep->status & S_MESSAGE_PERMFAILURE) { - struct message msave; - - messagep->status &= ~S_MESSAGE_PERMFAILURE; - if ((messagep->type & T_DAEMON_MESSAGE) == 0) { - msave = *messagep; - messagep->id = queue_generate_id(); - messagep->batch_id = 0; - messagep->type |= T_DAEMON_MESSAGE; - messagep->lasttry = 0; - messagep->retry = 0; - queue_record_envelope(messagep); - *messagep = msave; - } - queue_remove_envelope(messagep); - break; - } - - /* no error, remove envelope */ - queue_remove_envelope(messagep); + queue_message_update(imsg.data); break; } @@ -1182,6 +1119,41 @@ queue_delete_message(char *msgid) return; } +void +queue_message_update(struct message *messagep) +{ + struct message msave; + + messagep->batch_id = 0; + messagep->retry++; + + if (messagep->status & S_MESSAGE_PERMFAILURE) { + if ((messagep->type & T_DAEMON_MESSAGE) == 0) { + msave = *messagep; + messagep->id = queue_generate_id(); + messagep->batch_id = 0; + messagep->type |= T_DAEMON_MESSAGE; + messagep->status &= ~S_MESSAGE_PERMFAILURE; + messagep->lasttry = 0; + messagep->retry = 0; + queue_record_envelope(messagep); + *messagep = msave; + } + queue_remove_envelope(messagep); + return; + } + + if (messagep->status & S_MESSAGE_TEMPFAILURE) { + messagep->status &= ~S_MESSAGE_TEMPFAILURE; + messagep->flags &= ~F_MESSAGE_PROCESSING; + queue_update_envelope(messagep); + return; + } + + /* no error, remove envelope */ + queue_remove_envelope(messagep); +} + u_int16_t queue_hash(char *msgid) { |