summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/bounce.c10
-rw-r--r--usr.sbin/smtpd/queue.c14
-rw-r--r--usr.sbin/smtpd/queue_backend.c46
-rw-r--r--usr.sbin/smtpd/queue_fsqueue.c136
-rw-r--r--usr.sbin/smtpd/runner.c35
-rw-r--r--usr.sbin/smtpd/scheduler_ramqueue.c10
-rw-r--r--usr.sbin/smtpd/smtpctl.c14
-rw-r--r--usr.sbin/smtpd/smtpd.h36
8 files changed, 131 insertions, 170 deletions
diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c
index f83b3517cff..a235a7ee3d4 100644
--- a/usr.sbin/smtpd/bounce.c
+++ b/usr.sbin/smtpd/bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bounce.c,v 1.40 2012/01/29 11:37:32 eric Exp $ */
+/* $OpenBSD: bounce.c,v 1.41 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2009 Gilles Chehade <gilles@openbsd.org>
@@ -209,11 +209,11 @@ bounce_status(struct bounce *bounce, const char *fmt, ...)
if (*status == '2' || *status == '5' || *status == '6') {
log_debug("#### %s: queue_envelope_delete: %016" PRIx64,
__func__, bounce->evp.id);
- queue_envelope_delete(Q_QUEUE, &bounce->evp);
+ queue_envelope_delete(&bounce->evp);
} else {
bounce->evp.retry++;
envelope_set_errormsg(&bounce->evp, "%s", status);
- queue_envelope_update(Q_QUEUE, &bounce->evp);
+ queue_envelope_update(&bounce->evp);
}
bounce->evp.id = 0;
free(status);
@@ -316,7 +316,7 @@ bounce_session(int fd, struct envelope *evp)
log_debug("bounce: bouncing envelope id %016" PRIx64 "", evp->id);
/* get message content */
- if ((msgfd = queue_message_fd_r(Q_QUEUE, msgid)) == -1)
+ if ((msgfd = queue_message_fd_r(msgid)) == -1)
return (0);
msgfp = fdopen(msgfd, "r");
@@ -355,5 +355,5 @@ bounce_record_message(struct envelope *e, struct envelope *bounce)
bounce->type = D_BOUNCE;
bounce->retry = 0;
bounce->lasttry = 0;
- return (queue_envelope_create(Q_QUEUE, bounce));
+ return (queue_envelope_create(bounce));
}
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c
index 7f556ac2359..9437e95ca50 100644
--- a/usr.sbin/smtpd/queue.c
+++ b/usr.sbin/smtpd/queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue.c,v 1.118 2012/06/18 10:21:16 chl Exp $ */
+/* $OpenBSD: queue.c,v 1.119 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -61,7 +61,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
ss.id = e->session_id;
ss.code = 250;
ss.u.msgid = 0;
- ret = queue_message_create(Q_INCOMING, &ss.u.msgid);
+ ret = queue_message_create(&ss.u.msgid);
if (ret == 0)
ss.code = 421;
imsg_compose_event(iev, IMSG_QUEUE_CREATE_MESSAGE, 0, 0, -1,
@@ -69,13 +69,13 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
return;
case IMSG_QUEUE_REMOVE_MESSAGE:
- queue_message_delete(Q_INCOMING, evpid_to_msgid(e->id));
+ queue_message_delete(evpid_to_msgid(e->id));
return;
case IMSG_QUEUE_COMMIT_MESSAGE:
ss.id = e->session_id;
ss.code = 250;
- if (queue_message_commit(Q_INCOMING, evpid_to_msgid(e->id)))
+ if (queue_message_commit(evpid_to_msgid(e->id)))
stat_increment(e->flags & DF_ENQUEUED ?
STATS_QUEUE_LOCAL : STATS_QUEUE_REMOTE);
else
@@ -91,7 +91,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
case IMSG_QUEUE_MESSAGE_FILE:
ss.id = e->session_id;
- fd = queue_message_fd_rw(Q_INCOMING, evpid_to_msgid(e->id));
+ fd = queue_message_fd_rw(evpid_to_msgid(e->id));
if (fd == -1)
ss.code = 421;
imsg_compose_event(iev, IMSG_QUEUE_MESSAGE_FILE, 0, 0, fd,
@@ -110,7 +110,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
switch (imsg->hdr.type) {
case IMSG_QUEUE_SUBMIT_ENVELOPE:
ss.id = e->session_id;
- ret = queue_envelope_create(Q_INCOMING, e);
+ ret = queue_envelope_create(e);
if (ret == 0) {
ss.code = 421;
imsg_compose_event(env->sc_ievs[PROC_SMTP],
@@ -141,7 +141,7 @@ queue_imsg(struct imsgev *iev, struct imsg *imsg)
switch (imsg->hdr.type) {
case IMSG_QUEUE_MESSAGE_FD:
mta_batch = imsg->data;
- fd = queue_message_fd_r(Q_QUEUE, mta_batch->msgid);
+ fd = queue_message_fd_r(mta_batch->msgid);
imsg_compose_event(iev, IMSG_QUEUE_MESSAGE_FD, 0, 0,
fd, mta_batch, sizeof *mta_batch);
return;
diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c
index 2123001594f..f539eb0d2b8 100644
--- a/usr.sbin/smtpd/queue_backend.c
+++ b/usr.sbin/smtpd/queue_backend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_backend.c,v 1.23 2012/06/08 11:34:23 chl Exp $ */
+/* $OpenBSD: queue_backend.c,v 1.24 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -59,48 +59,48 @@ queue_backend_lookup(enum queue_type type)
}
int
-queue_message_create(enum queue_kind qkind, u_int32_t *msgid)
+queue_message_create(u_int32_t *msgid)
{
- return env->sc_queue->message(qkind, QOP_CREATE, msgid);
+ return env->sc_queue->message(QOP_CREATE, msgid);
}
int
-queue_message_delete(enum queue_kind qkind, u_int32_t msgid)
+queue_message_delete(u_int32_t msgid)
{
- return env->sc_queue->message(qkind, QOP_DELETE, &msgid);
+ return env->sc_queue->message(QOP_DELETE, &msgid);
}
int
-queue_message_commit(enum queue_kind qkind, u_int32_t msgid)
+queue_message_commit(u_int32_t msgid)
{
- return env->sc_queue->message(qkind, QOP_COMMIT, &msgid);
+ return env->sc_queue->message(QOP_COMMIT, &msgid);
}
int
-queue_message_corrupt(enum queue_kind qkind, u_int32_t msgid)
+queue_message_corrupt(u_int32_t msgid)
{
- return env->sc_queue->message(qkind, QOP_CORRUPT, &msgid);
+ return env->sc_queue->message(QOP_CORRUPT, &msgid);
}
int
-queue_message_fd_r(enum queue_kind qkind, u_int32_t msgid)
+queue_message_fd_r(u_int32_t msgid)
{
- return env->sc_queue->message(qkind, QOP_FD_R, &msgid);
+ return env->sc_queue->message(QOP_FD_R, &msgid);
}
int
-queue_message_fd_rw(enum queue_kind qkind, u_int32_t msgid)
+queue_message_fd_rw(u_int32_t msgid)
{
- return env->sc_queue->message(qkind, QOP_FD_RW, &msgid);
+ return env->sc_queue->message(QOP_FD_RW, &msgid);
}
int
-queue_envelope_create(enum queue_kind qkind, struct envelope *ep)
+queue_envelope_create(struct envelope *ep)
{
int r;
ep->creation = time(NULL);
- r = env->sc_queue->envelope(qkind, QOP_CREATE, ep);
+ r = env->sc_queue->envelope(QOP_CREATE, ep);
if (!r) {
ep->creation = 0;
ep->id = 0;
@@ -109,18 +109,18 @@ queue_envelope_create(enum queue_kind qkind, struct envelope *ep)
}
int
-queue_envelope_delete(enum queue_kind qkind, struct envelope *ep)
+queue_envelope_delete(struct envelope *ep)
{
- return env->sc_queue->envelope(qkind, QOP_DELETE, ep);
+ return env->sc_queue->envelope(QOP_DELETE, ep);
}
int
-queue_envelope_load(enum queue_kind qkind, u_int64_t evpid, struct envelope *ep)
+queue_envelope_load(u_int64_t evpid, struct envelope *ep)
{
const char *e;
ep->id = evpid;
- if (env->sc_queue->envelope(qkind, QOP_LOAD, ep)) {
+ if (env->sc_queue->envelope(QOP_LOAD, ep)) {
if ((e = envelope_validate(ep, evpid)) == NULL) {
ep->id = evpid;
return (1);
@@ -131,15 +131,15 @@ queue_envelope_load(enum queue_kind qkind, u_int64_t evpid, struct envelope *ep)
}
int
-queue_envelope_update(enum queue_kind qkind, struct envelope *ep)
+queue_envelope_update(struct envelope *ep)
{
- return env->sc_queue->envelope(qkind, QOP_UPDATE, ep);
+ return env->sc_queue->envelope(QOP_UPDATE, ep);
}
void *
-qwalk_new(enum queue_kind kind, u_int32_t msgid)
+qwalk_new(u_int32_t msgid)
{
- return env->sc_queue->qwalk_new(kind, msgid);
+ return env->sc_queue->qwalk_new(msgid);
}
int
diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c
index 2113ae42f6f..60b946fc213 100644
--- a/usr.sbin/smtpd/queue_fsqueue.c
+++ b/usr.sbin/smtpd/queue_fsqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_fsqueue.c,v 1.41 2012/06/01 11:42:34 eric Exp $ */
+/* $OpenBSD: queue_fsqueue.c,v 1.42 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -42,7 +42,11 @@
#include "smtpd.h"
#include "log.h"
-static char *fsqueue_getpath(enum queue_kind);
+enum queue_kind {
+ Q_INCOMING,
+ Q_QUEUE,
+ Q_CORRUPT
+};
static int fsqueue_envelope_load(enum queue_kind, struct envelope *);
static int fsqueue_envelope_update(enum queue_kind, struct envelope *);
@@ -60,12 +64,12 @@ static int fsqueue_envelope_path(enum queue_kind, u_int64_t, char *, size_t);
static int fsqueue_envelope_dump_atomic(char *, struct envelope *);
int fsqueue_init(int);
-int fsqueue_message(enum queue_kind, enum queue_op, u_int32_t *);
-int fsqueue_envelope(enum queue_kind, enum queue_op , struct envelope *);
+int fsqueue_message(enum queue_op, u_int32_t *);
+int fsqueue_envelope(enum queue_op , struct envelope *);
int fsqueue_load_envelope_ascii(FILE *, struct envelope *);
int fsqueue_dump_envelope_ascii(FILE *, struct envelope *);
-void *fsqueue_qwalk_new(enum queue_kind, u_int32_t);
+void *fsqueue_qwalk_new(u_int32_t);
int fsqueue_qwalk(void *, u_int64_t *);
void fsqueue_qwalk_close(void *);
@@ -87,53 +91,47 @@ struct queue_backend queue_backend_fs = {
fsqueue_qwalk_close
};
-static char *
-fsqueue_getpath(enum queue_kind kind)
-{
- switch (kind) {
- case Q_INCOMING:
- return (PATH_INCOMING);
-
- case Q_QUEUE:
- return (PATH_QUEUE);
-
- case Q_CORRUPT:
- return (PATH_CORRUPT);
-
- default:
- fatalx("queue_fsqueue_getpath: unsupported queue kind.");
- }
- return NULL;
-}
-
static int
fsqueue_message_path(enum queue_kind qkind, uint32_t msgid, char *buf, size_t len)
{
- if (qkind == Q_QUEUE)
+ switch (qkind) {
+ case Q_QUEUE:
return bsnprintf(buf, len, "%s/%03x/%08x",
- fsqueue_getpath(qkind),
+ PATH_QUEUE,
msgid & 0xfff,
msgid);
- else
+ case Q_INCOMING:
+ case Q_CORRUPT:
return bsnprintf(buf, len, "%s/%08x",
- fsqueue_getpath(qkind),
+ qkind == Q_INCOMING ? PATH_INCOMING : PATH_CORRUPT,
msgid);
+ default:
+ fatalx("fsqueue_message_path: unsupported queue kind.");
+ }
+ return (0);
}
static int
fsqueue_envelope_path(enum queue_kind qkind, uint64_t evpid, char *buf, size_t len)
{
- if (qkind == Q_QUEUE)
+ switch (qkind) {
+ case Q_QUEUE:
return bsnprintf(buf, len, "%s/%03x/%08x%s/%016" PRIx64,
- fsqueue_getpath(qkind),
+ PATH_QUEUE,
evpid_to_msgid(evpid) & 0xfff,
evpid_to_msgid(evpid),
PATH_ENVELOPES, evpid);
- else
+ case Q_INCOMING:
+ case Q_CORRUPT:
return bsnprintf(buf, len, "%s/%08x%s/%016" PRIx64,
- fsqueue_getpath(qkind),
+ qkind == Q_INCOMING ? PATH_INCOMING : PATH_CORRUPT,
evpid_to_msgid(evpid),
PATH_ENVELOPES, evpid);
+ default:
+ fatalx("fsqueue_envelope_path: unsupported queue kind.");
+ }
+
+ return (0);
}
static int
@@ -416,26 +414,26 @@ fsqueue_init(int server)
}
int
-fsqueue_message(enum queue_kind qkind, enum queue_op qop, u_int32_t *msgid)
+fsqueue_message(enum queue_op qop, u_int32_t *msgid)
{
switch (qop) {
case QOP_CREATE:
- return fsqueue_message_create(qkind, msgid);
+ return fsqueue_message_create(Q_INCOMING, msgid);
case QOP_DELETE:
- return fsqueue_message_delete(qkind, *msgid);
+ return fsqueue_message_delete(Q_INCOMING, *msgid);
case QOP_COMMIT:
- return fsqueue_message_commit(qkind, *msgid);
+ return fsqueue_message_commit(Q_INCOMING, *msgid);
case QOP_FD_R:
- return fsqueue_message_fd_r(qkind, *msgid);
+ return fsqueue_message_fd_r(Q_QUEUE, *msgid);
case QOP_FD_RW:
- return fsqueue_message_fd_rw(qkind, *msgid);
+ return fsqueue_message_fd_rw(Q_INCOMING, *msgid);
case QOP_CORRUPT:
- return fsqueue_message_corrupt(qkind, *msgid);
+ return fsqueue_message_corrupt(Q_QUEUE, *msgid);
default:
fatalx("queue_fsqueue_message: unsupported operation.");
@@ -445,20 +443,24 @@ fsqueue_message(enum queue_kind qkind, enum queue_op qop, u_int32_t *msgid)
}
int
-fsqueue_envelope(enum queue_kind qkind, enum queue_op qop, struct envelope *m)
+fsqueue_envelope(enum queue_op qop, struct envelope *m)
{
switch (qop) {
case QOP_CREATE:
- return fsqueue_envelope_create(qkind, m);
+ /* currently, only bounce envelopes are created in queued
+ * messages
+ */
+ return fsqueue_envelope_create(
+ m->type == D_BOUNCE ? Q_QUEUE : Q_INCOMING, m);
case QOP_DELETE:
- return fsqueue_envelope_delete(qkind, m);
+ return fsqueue_envelope_delete(Q_QUEUE, m);
case QOP_LOAD:
- return fsqueue_envelope_load(qkind, m);
+ return fsqueue_envelope_load(Q_QUEUE, m);
case QOP_UPDATE:
- return fsqueue_envelope_update(qkind, m);
+ return fsqueue_envelope_update(Q_QUEUE, m);
default:
fatalx("queue_fsqueue_envelope: unsupported operation.");
@@ -472,7 +474,6 @@ fsqueue_envelope(enum queue_kind qkind, enum queue_op qop, struct envelope *m)
#define QWALK_RETURN 0x3
struct qwalk {
- enum queue_kind kind;
char path[MAXPATHLEN];
DIR *dirs[3];
int (*filefn)(struct qwalk *, char *);
@@ -481,12 +482,10 @@ struct qwalk {
u_int32_t msgid;
};
-int walk_simple(struct qwalk *, char *);
-int walk_queue(struct qwalk *, char *);
-int walk_queue_nobucket(struct qwalk *, char *);
+int walk_queue(struct qwalk *, char *);
void *
-fsqueue_qwalk_new(enum queue_kind kind, u_int32_t msgid)
+fsqueue_qwalk_new(u_int32_t msgid)
{
struct qwalk *q;
@@ -494,12 +493,9 @@ fsqueue_qwalk_new(enum queue_kind kind, u_int32_t msgid)
if (q == NULL)
fatal("qwalk_new: calloc");
- strlcpy(q->path, fsqueue_getpath(kind),
- sizeof(q->path));
+ strlcpy(q->path, PATH_QUEUE, sizeof(q->path));
- q->kind = kind;
q->level = 0;
- q->filefn = walk_simple;
q->msgid = msgid;
if (q->msgid) {
@@ -510,12 +506,7 @@ fsqueue_qwalk_new(enum queue_kind kind, u_int32_t msgid)
PATH_QUEUE, q->bucket, q->msgid, PATH_ENVELOPES))
fatalx("walk_queue: snprintf");
}
-
- if (kind == Q_QUEUE)
- q->filefn = walk_queue;
- if (kind == Q_INCOMING)
- q->filefn = walk_queue_nobucket;
-
+ q->filefn = walk_queue;
q->dirs[q->level] = opendir(q->path);
if (q->dirs[q->level] == NULL)
fatal("qwalk_new: opendir");
@@ -597,13 +588,6 @@ fsqueue_qwalk_close(void *hdl)
free(q);
}
-
-int
-walk_simple(struct qwalk *q, char *fname)
-{
- return (QWALK_RETURN);
-}
-
int
walk_queue(struct qwalk *q, char *fname)
{
@@ -621,12 +605,12 @@ walk_queue(struct qwalk *q, char *fname)
return (QWALK_AGAIN);
}
if (! bsnprintf(q->path, sizeof(q->path), "%s/%03x",
- fsqueue_getpath(q->kind), q->bucket & 0xfff))
+ PATH_QUEUE, q->bucket & 0xfff))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);
case 1:
if (! bsnprintf(q->path, sizeof(q->path), "%s/%03x/%s%s",
- fsqueue_getpath(q->kind), q->bucket & 0xfff, fname,
+ PATH_QUEUE, q->bucket & 0xfff, fname,
PATH_ENVELOPES))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);
@@ -636,19 +620,3 @@ walk_queue(struct qwalk *q, char *fname)
return (-1);
}
-
-int
-walk_queue_nobucket(struct qwalk *q, char *fname)
-{
- switch (q->level) {
- case 0:
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%s%s",
- fsqueue_getpath(q->kind), fname, PATH_ENVELOPES))
- fatalx("walk_queue_nobucket: snprintf");
- return (QWALK_RECURSE);
- case 1:
- return (QWALK_RETURN);
- }
-
- return (-1);
-}
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 00d8c6b112f..4c3ac999d68 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.140 2012/06/20 20:27:41 eric Exp $ */
+/* $OpenBSD: runner.c,v 1.141 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -80,14 +80,14 @@ runner_imsg(struct imsgev *iev, struct imsg *imsg)
e = imsg->data;
log_debug("queue_delivery_ok: %016"PRIx64, e->id);
scheduler->remove(e->id);
- queue_envelope_delete(Q_QUEUE, e);
+ queue_envelope_delete(e);
return;
case IMSG_QUEUE_DELIVERY_TEMPFAIL:
stat_decrement(STATS_RUNNER);
e = imsg->data;
e->retry++;
- queue_envelope_update(Q_QUEUE, e);
+ queue_envelope_update(e);
log_debug("queue_delivery_tempfail: %016"PRIx64, e->id);
scheduler_info(&si, e);
scheduler->insert(&si);
@@ -106,7 +106,7 @@ runner_imsg(struct imsgev *iev, struct imsg *imsg)
runner_reset_events();
}
scheduler->remove(e->id);
- queue_envelope_delete(Q_QUEUE, e);
+ queue_envelope_delete(e);
return;
case IMSG_MDA_SESS_NEW:
@@ -126,7 +126,7 @@ runner_imsg(struct imsgev *iev, struct imsg *imsg)
case IMSG_SMTP_ENQUEUE:
e = imsg->data;
if (imsg->fd < 0 || !bounce_session(imsg->fd, e)) {
- queue_envelope_update(Q_QUEUE, e);
+ queue_envelope_update(e);
log_debug("smtp_enqueue: %016"PRIx64, e->id);
scheduler_info(&si, e);
scheduler->insert(&si);
@@ -365,7 +365,7 @@ runner_process_envelope(u_int64_t evpid)
mda_av = env->sc_maxconn - stat_get(STATS_MDA_SESSION, STAT_ACTIVE);
bnc_av = env->sc_maxconn - stat_get(STATS_RUNNER_BOUNCES, STAT_ACTIVE);
- if (! queue_envelope_load(Q_QUEUE, evpid, &envelope))
+ if (! queue_envelope_load(evpid, &envelope))
return 0;
if (envelope.type == D_MDA)
@@ -395,9 +395,10 @@ runner_process_envelope(u_int64_t evpid)
scheduler->insert(&si);
}
scheduler->remove(evpid);
- queue_envelope_delete(Q_QUEUE, &envelope);
+ queue_envelope_delete(&envelope);
runner_reset_events();
+
return 0;
}
@@ -416,7 +417,7 @@ runner_process_batch(enum delivery_type type, u_int64_t evpid)
switch (type) {
case D_BOUNCE:
while (scheduler->fetch(batch, &evpid)) {
- if (! queue_envelope_load(Q_QUEUE, evpid, &evp))
+ if (! queue_envelope_load(evpid, &evp))
goto end;
evp.lasttry = time(NULL);
@@ -431,11 +432,11 @@ runner_process_batch(enum delivery_type type, u_int64_t evpid)
case D_MDA:
scheduler->fetch(batch, &evpid);
- if (! queue_envelope_load(Q_QUEUE, evpid, &evp))
+ if (! queue_envelope_load(evpid, &evp))
goto end;
evp.lasttry = time(NULL);
- fd = queue_message_fd_r(Q_QUEUE, evpid_to_msgid(evpid));
+ fd = queue_message_fd_r(evpid_to_msgid(evpid));
imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_MDA_SESS_NEW, PROC_MDA, 0, fd, &evp,
sizeof evp);
@@ -451,7 +452,7 @@ runner_process_batch(enum delivery_type type, u_int64_t evpid)
/* FIXME */
if (! scheduler->fetch(batch, &evpid))
goto end;
- if (! queue_envelope_load(Q_QUEUE, evpid,
+ if (! queue_envelope_load(evpid,
&evp))
goto end;
@@ -464,7 +465,7 @@ runner_process_batch(enum delivery_type type, u_int64_t evpid)
sizeof mta_batch);
while (scheduler->fetch(batch, &evpid)) {
- if (! queue_envelope_load(Q_QUEUE, evpid,
+ if (! queue_envelope_load(evpid,
&evp))
goto end;
evp.lasttry = time(NULL); /* FIXME */
@@ -503,10 +504,9 @@ runner_message_to_scheduler(u_int32_t msgid)
struct envelope envelope;
struct scheduler_info si;
- q = qwalk_new(Q_QUEUE, msgid);
+ q = qwalk_new(msgid);
while (qwalk(q, &evpid)) {
- if (! queue_envelope_load(Q_QUEUE, evpid,
- &envelope))
+ if (! queue_envelope_load(evpid, &envelope))
continue;
scheduler_info(&si, &envelope);
scheduler->insert(&si);
@@ -527,8 +527,7 @@ runner_check_loop(struct envelope *ep)
int ret = 0;
int rcvcount = 0;
- fd = queue_message_fd_r(Q_QUEUE,
- evpid_to_msgid(ep->id));
+ fd = queue_message_fd_r(evpid_to_msgid(ep->id));
if ((fp = fdopen(fd, "r")) == NULL)
fatal("fdopen");
@@ -604,6 +603,6 @@ runner_remove_envelope(u_int64_t evpid)
struct envelope evp;
evp.id = evpid;
- queue_envelope_delete(Q_QUEUE, &evp);
+ queue_envelope_delete(&evp);
scheduler->remove(evpid);
}
diff --git a/usr.sbin/smtpd/scheduler_ramqueue.c b/usr.sbin/smtpd/scheduler_ramqueue.c
index 8e0020f3bed..baa675d532e 100644
--- a/usr.sbin/smtpd/scheduler_ramqueue.c
+++ b/usr.sbin/smtpd/scheduler_ramqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scheduler_ramqueue.c,v 1.9 2012/06/17 15:17:08 gilles Exp $ */
+/* $OpenBSD: scheduler_ramqueue.c,v 1.10 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2012 Gilles Chehade <gilles@openbsd.org>
@@ -248,7 +248,7 @@ scheduler_ramqueue_setup(time_t curtm, time_t nsched)
log_info("scheduler_ramqueue: queue loading in progress");
if (q == NULL)
- q = qwalk_new(Q_QUEUE, 0);
+ q = qwalk_new(0);
while (qwalk(q, &evpid)) {
/* the envelope is already in ramqueue, skip */
@@ -256,9 +256,9 @@ scheduler_ramqueue_setup(time_t curtm, time_t nsched)
ramqueue_lookup_offload(evpid))
continue;
- if (! queue_envelope_load(Q_QUEUE, evpid, &envelope)) {
+ if (! queue_envelope_load(evpid, &envelope)) {
log_debug("scheduler_ramqueue: evp -> /corrupt");
- queue_message_corrupt(Q_QUEUE, evpid_to_msgid(evpid));
+ queue_message_corrupt(evpid_to_msgid(evpid));
continue;
}
if (ramqueue_expire(&envelope, curtm))
@@ -685,7 +685,7 @@ ramqueue_expire(struct envelope *envelope, time_t curtm)
log_debug("#### %s: queue_envelope_delete: %016" PRIx64,
__func__, envelope->id);
- queue_envelope_delete(Q_QUEUE, envelope);
+ queue_envelope_delete(envelope);
return 1;
}
return 0;
diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c
index de9d0653a5e..0926c5f7143 100644
--- a/usr.sbin/smtpd/smtpctl.c
+++ b/usr.sbin/smtpd/smtpctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpctl.c,v 1.80 2012/05/13 09:18:52 nicm Exp $ */
+/* $OpenBSD: smtpctl.c,v 1.81 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -46,7 +46,7 @@ void usage(void);
static void setup_env(struct smtpd *);
static int show_command_output(struct imsg *);
static int show_stats_output(struct imsg *);
-static void show_queue(enum queue_kind, int);
+static void show_queue(int);
static void show_envelope(struct envelope *, int);
static void getflag(u_int *, int, char *, char *, size_t);
@@ -106,7 +106,7 @@ main(int argc, char *argv[])
if (geteuid())
errx(1, "need root privileges");
setup_env(&smtpd);
- show_queue(Q_QUEUE, 0);
+ show_queue(0);
return 0;
} else if (strcmp(__progname, "smtpctl") == 0) {
@@ -122,7 +122,7 @@ main(int argc, char *argv[])
/* handle "disconnected" commands */
switch (res->action) {
case SHOW_QUEUE:
- show_queue(Q_QUEUE, 0);
+ show_queue(0);
break;
case SHOW_RUNQUEUE:
break;
@@ -437,7 +437,7 @@ show_stats_output(struct imsg *imsg)
}
static void
-show_queue(enum queue_kind kind, int flags)
+show_queue(int flags)
{
struct qwalk *q;
struct envelope envelope;
@@ -448,10 +448,10 @@ show_queue(enum queue_kind kind, int flags)
if (chroot(PATH_SPOOL) == -1 || chdir(".") == -1)
err(1, "%s", PATH_SPOOL);
- q = qwalk_new(kind, 0);
+ q = qwalk_new(0);
while (qwalk(q, &evpid)) {
- if (! queue_envelope_load(kind, evpid, &envelope))
+ if (! queue_envelope_load(evpid, &envelope))
continue;
show_envelope(&envelope, flags);
}
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index b0b23fd5309..57bb6422181 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.300 2012/06/17 15:17:08 gilles Exp $ */
+/* $OpenBSD: smtpd.h,v 1.301 2012/06/20 20:45:23 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -892,12 +892,6 @@ enum queue_type {
QT_FS
};
-enum queue_kind {
- Q_INCOMING,
- Q_QUEUE,
- Q_CORRUPT
-};
-
enum queue_op {
QOP_INVALID=0,
QOP_CREATE,
@@ -912,10 +906,10 @@ enum queue_op {
struct queue_backend {
int (*init)(int);
- int (*message)(enum queue_kind, enum queue_op, u_int32_t *);
- int (*envelope)(enum queue_kind, enum queue_op, struct envelope *);
+ int (*message)(enum queue_op, u_int32_t *);
+ int (*envelope)(enum queue_op, struct envelope *);
- void *(*qwalk_new)(enum queue_kind, u_int32_t);
+ void *(*qwalk_new)(u_int32_t);
int (*qwalk)(void *, u_int64_t *);
void (*qwalk_close)(void *);
};
@@ -1128,17 +1122,17 @@ void queue_commit_envelopes(struct envelope *);
u_int32_t queue_generate_msgid(void);
u_int64_t queue_generate_evpid(u_int32_t msgid);
struct queue_backend *queue_backend_lookup(enum queue_type);
-int queue_message_create(enum queue_kind, u_int32_t *);
-int queue_message_delete(enum queue_kind, u_int32_t);
-int queue_message_commit(enum queue_kind, u_int32_t);
-int queue_message_fd_r(enum queue_kind, u_int32_t);
-int queue_message_fd_rw(enum queue_kind, u_int32_t);
-int queue_message_corrupt(enum queue_kind, u_int32_t);
-int queue_envelope_create(enum queue_kind, struct envelope *);
-int queue_envelope_delete(enum queue_kind, struct envelope *);
-int queue_envelope_load(enum queue_kind, u_int64_t, struct envelope *);
-int queue_envelope_update(enum queue_kind, struct envelope *);
-void *qwalk_new(enum queue_kind, u_int32_t);
+int queue_message_create(u_int32_t *);
+int queue_message_delete(u_int32_t);
+int queue_message_commit(u_int32_t);
+int queue_message_fd_r(u_int32_t);
+int queue_message_fd_rw(u_int32_t);
+int queue_message_corrupt(u_int32_t);
+int queue_envelope_create(struct envelope *);
+int queue_envelope_delete(struct envelope *);
+int queue_envelope_load(u_int64_t, struct envelope *);
+int queue_envelope_update(struct envelope *);
+void *qwalk_new(u_int32_t);
int qwalk(void *, u_int64_t *);
void qwalk_close(void *);