summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/scheduler.c
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@cvs.openbsd.org>2015-10-29 10:25:37 +0000
committerSunil Nimmagadda <sunil@cvs.openbsd.org>2015-10-29 10:25:37 +0000
commit6c0eaa4eab312f87ef3562152378dabe1c005fc8 (patch)
tree05b21e520b910637db09489d6dd5dcfaab580569 /usr.sbin/smtpd/scheduler.c
parent378b858d8b519862641947a367dced9c6559bcdd (diff)
Implement smtpctl discover <evpid|msgid>.
discover subcommand schedules envelopes manually moved to the queue. It triggers a queue walk searching for envelopes with the given id, schedules them and informs the user number of envelopes scheduled. Admins no longer would need to restart the daemon to discover manually moved messages. Ok gilles@
Diffstat (limited to 'usr.sbin/smtpd/scheduler.c')
-rw-r--r--usr.sbin/smtpd/scheduler.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/scheduler.c b/usr.sbin/smtpd/scheduler.c
index 171b99d3de1..94c0a608610 100644
--- a/usr.sbin/smtpd/scheduler.c
+++ b/usr.sbin/smtpd/scheduler.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler.c,v 1.49 2015/10/13 08:09:25 gilles Exp $ */
+/* $OpenBSD: scheduler.c,v 1.50 2015/10/29 10:25:36 sunil Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@@ -100,6 +100,41 @@ scheduler_imsg(struct mproc *p, struct imsg *imsg)
scheduler_reset_events();
return;
+ case IMSG_QUEUE_DISCOVER_EVPID:
+ m_msg(&m, imsg);
+ m_get_envelope(&m, &evp);
+ m_end(&m);
+ r = backend->query(evp.id);
+ if (r) {
+ log_debug("debug: scheduler: evp:%016" PRIx64
+ " already scheduled", evp.id);
+ return;
+ }
+ log_trace(TRACE_SCHEDULER,
+ "scheduler: discovering evp:%016" PRIx64, evp.id);
+ scheduler_info(&si, &evp);
+ stat_increment("scheduler.envelope.incoming", 1);
+ backend->insert(&si);
+ return;
+
+ case IMSG_QUEUE_DISCOVER_MSGID:
+ m_msg(&m, imsg);
+ m_get_msgid(&m, &msgid);
+ m_end(&m);
+ r = backend->query(msgid);
+ if (r) {
+ log_debug("debug: scheduler: msgid:%08" PRIx32
+ " already scheduled", msgid);
+ return;
+ }
+ log_trace(TRACE_SCHEDULER,
+ "scheduler: committing msg:%08" PRIx32, msgid);
+ n = backend->commit(msgid);
+ stat_decrement("scheduler.envelope.incoming", n);
+ stat_increment("scheduler.envelope", n);
+ scheduler_reset_events();
+ return;
+
case IMSG_QUEUE_MESSAGE_ROLLBACK:
m_msg(&m, imsg);
m_get_msgid(&m, &msgid);