summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/runner.c
diff options
context:
space:
mode:
authorJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-01-08 19:15:24 +0000
committerJacek Masiulaniec <jacekm@cvs.openbsd.org>2009-01-08 19:15:24 +0000
commitc27b3e884589b1df29966bfdef5271754910be6a (patch)
treeaf6876ff42cf6b38cf55a25db5bb8b8c917243f9 /usr.sbin/smtpd/runner.c
parent6866b20bcd152d1a2a3653b7373ee7bb911f540c (diff)
clear processing flags early so that there's never doubt whether they
belong to previous or current smtpd instance; ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/runner.c')
-rw-r--r--usr.sbin/smtpd/runner.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 38a353a25a2..6eb3dd967eb 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.21 2009/01/06 23:02:07 jacekm Exp $ */
+/* $OpenBSD: runner.c,v 1.22 2009/01/08 19:15:23 jacekm Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -52,6 +52,9 @@ void runner_dispatch_mta(int, short, void *);
void runner_dispatch_lka(int, short, void *);
void runner_setup_events(struct smtpd *);
void runner_disable_events(struct smtpd *);
+
+int runner_reset_flags(void);
+
void runner_timeout(int, short, void *);
void runner_process_envelope(struct message *);
@@ -72,8 +75,6 @@ void runner_purge_message(char *);
struct batch *batch_record(struct smtpd *, struct message *);
struct batch *batch_lookup(struct smtpd *, struct message *);
-u_int8_t flagreset = 1;
-
static DIR *curdir, *dir_queue, *dir_bucket, *dir_envelope;
void
@@ -423,6 +424,9 @@ runner(struct smtpd *env)
config_peers(env, peers, 5);
+ while (! runner_reset_flags())
+ sleep(1);
+
runner_setup_events(env);
event_dispatch();
runner_shutdown();
@@ -430,6 +434,24 @@ runner(struct smtpd *env)
return (0);
}
+int
+runner_reset_flags(void)
+{
+ struct message message;
+
+ runner_envelope_rewind();
+
+ while (runner_envelope_next(&message)) {
+ message.flags &= ~F_MESSAGE_SCHEDULED;
+ message.flags &= ~F_MESSAGE_PROCESSING;
+
+ if (! queue_update_envelope(&message))
+ return 0;
+ }
+
+ return 1;
+}
+
void
runner_timeout(int fd, short event, void *p)
{
@@ -452,7 +474,6 @@ runner_timeout(int fd, short event, void *p)
runner_process_envelope(&message);
}
- flagreset = 0;
runner_process_runqueue(env);
runner_process_batchqueue(env);
@@ -468,11 +489,6 @@ runner_process_envelope(struct message *messagep)
char rqpath[MAXPATHLEN];
struct stat sb;
- if (flagreset) {
- messagep->flags &= ~(F_MESSAGE_SCHEDULED|F_MESSAGE_PROCESSING);
- queue_update_envelope(messagep);
- }
-
if (! runner_message_schedule(messagep, time(NULL)))
return;