diff options
author | Eric Faurot <eric@cvs.openbsd.org> | 2012-11-23 09:25:45 +0000 |
---|---|---|
committer | Eric Faurot <eric@cvs.openbsd.org> | 2012-11-23 09:25:45 +0000 |
commit | 23bce6aeda84d214fb7ec2b091f5f15167c8d3fb (patch) | |
tree | 5f760e85805d1343fec336de9a025ed223572293 | |
parent | 48da79ef884f444b89831aac87683c10daa45c77 (diff) |
Replace the qwalk API (to retreive on disk envelopes at runtime) with
a simple QOP_WALK queue operation. Some knf and formating fixes while
there.
ok gilles@
-rw-r--r-- | usr.sbin/smtpd/queue.c | 58 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue_backend.c | 54 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue_fsqueue.c | 110 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpctl.c | 18 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 184 |
5 files changed, 205 insertions, 219 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 8bde4360274..a0841774ea2 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.143 2012/11/20 09:47:45 eric Exp $ */ +/* $OpenBSD: queue.c,v 1.144 2012/11/23 09:25:44 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -437,51 +437,33 @@ queue(void) static void queue_timeout(int fd, short event, void *p) { - static struct qwalk *q = NULL; - static uint32_t msgid = 0; - static size_t evpcount = 0; - struct event *ev = p; - struct envelope envelope; - struct timeval tv; - uint64_t evpid; - - if (q == NULL) { - log_debug("debug: queue: loading queue into scheduler"); - q = qwalk_new(0); - } - - while (qwalk(q, &evpid)) { + static uint32_t msgid = 0; + struct envelope evp; + struct event *ev = p; + struct timeval tv; + int r; - if (msgid && evpid_to_msgid(evpid) != msgid && evpcount) { + r = queue_envelope_walk(&evp); + if (r == -1) { + if (msgid) imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, sizeof msgid); - evpcount = 0; - } - msgid = evpid_to_msgid(evpid); - - if (!queue_envelope_load(evpid, &envelope)) - log_warnx("warn: Failed to load envelope %016"PRIx64, - evpid); - else { - imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], - IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1, &envelope, - sizeof envelope); - evpcount++; - } - - tv.tv_sec = 0; - tv.tv_usec = 0; - evtimer_add(ev, &tv); + log_debug("debug: queue: done loading queue into scheduler"); return; } - if (msgid && evpcount) { + if (r) { + if (msgid && evpid_to_msgid(evp.id) != msgid) + imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], + IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, + sizeof msgid); + msgid = evpid_to_msgid(evp.id); imsg_compose_event(env->sc_ievs[PROC_SCHEDULER], - IMSG_QUEUE_COMMIT_MESSAGE, 0, 0, -1, &msgid, sizeof msgid); - evpcount = 0; + IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1, &evp, sizeof evp); } - log_debug("debug: queue: done loading queue into scheduler"); - qwalk_close(q); + tv.tv_sec = 0; + tv.tv_usec = 10; + evtimer_add(ev, &tv); } diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index 27cef8be6fb..b502bb18eee 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.40 2012/11/12 14:58:53 eric Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.41 2012/11/23 09:25:44 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -43,6 +43,7 @@ static const char* envelope_validate(struct envelope *); extern struct queue_backend queue_backend_fs; +extern struct queue_backend queue_backend_ram; int queue_message_incoming_path(uint32_t msgid, char *buf, size_t len) @@ -213,7 +214,8 @@ queue_envelope_dump_buffer(struct envelope *ep, char *evpbuf, size_t evpbufsize) return (0); if (env->sc_queue_flags & QUEUE_COMPRESS) { - evplen = compress_buffer(evp, evplen, evpbufcom, sizeof evpbufcom); + evplen = compress_buffer(evp, evplen, evpbufcom, + sizeof evpbufcom); if (evplen == 0) return (0); evp = evpbufcom; @@ -235,7 +237,8 @@ queue_envelope_load_buffer(struct envelope *ep, char *evpbuf, size_t evpbufsize) evplen = evpbufsize; if (env->sc_queue_flags & QUEUE_COMPRESS) { - evplen = uncompress_buffer(evp, evplen, evpbufcom, sizeof evpbufcom); + evplen = uncompress_buffer(evp, evplen, evpbufcom, + sizeof evpbufcom); if (evplen == 0) return (0); evp = evpbufcom; @@ -278,16 +281,18 @@ queue_envelope_load(uint64_t evpid, struct envelope *ep) size_t evplen; ep->id = evpid; - evplen = env->sc_queue->envelope(QOP_LOAD, &ep->id, evpbuf, sizeof evpbuf); + evplen = env->sc_queue->envelope(QOP_LOAD, &ep->id, evpbuf, + sizeof evpbuf); if (evplen == 0) return (0); - + if (queue_envelope_load_buffer(ep, evpbuf, evplen)) { if ((e = envelope_validate(ep)) == NULL) { ep->id = evpid; return (1); } - log_debug("debug: invalid envelope %016" PRIx64 ": %s", ep->id, e); + log_debug("debug: invalid envelope %016" PRIx64 ": %s", + ep->id, e); } return (0); } @@ -305,22 +310,27 @@ queue_envelope_update(struct envelope *ep) return env->sc_queue->envelope(QOP_UPDATE, &ep->id, evpbuf, evplen); } -void * -qwalk_new(uint32_t msgid) -{ - return env->sc_queue->qwalk_new(msgid); -} - int -qwalk(void *hdl, uint64_t *evpid) +queue_envelope_walk(struct envelope *ep) { - return env->sc_queue->qwalk(hdl, evpid); -} + const char *e; + uint64_t evpid; + char evpbuf[sizeof(struct envelope)]; + int r; -void -qwalk_close(void *hdl) -{ - return env->sc_queue->qwalk_close(hdl); + r = env->sc_queue->envelope(QOP_WALK, &evpid, evpbuf, sizeof evpbuf); + if (r == -1 || r == 0) + return (r); + + if (queue_envelope_load_buffer(ep, evpbuf, (size_t)r)) { + if ((e = envelope_validate(ep)) == NULL) { + ep->id = evpid; + return (1); + } + log_debug("debug: invalid envelope %016" PRIx64 ": %s", + ep->id, e); + } + return (0); } uint32_t @@ -328,7 +338,7 @@ queue_generate_msgid(void) { uint32_t msgid; - while((msgid = arc4random_uniform(0xffffffff)) == 0) + while ((msgid = arc4random_uniform(0xffffffff)) == 0) ; return msgid; @@ -340,7 +350,7 @@ queue_generate_evpid(uint32_t msgid) uint32_t rnd; uint64_t evpid; - while((rnd = arc4random_uniform(0xffffffff)) == 0) + while ((rnd = arc4random_uniform(0xffffffff)) == 0) ; evpid = msgid; @@ -350,8 +360,6 @@ queue_generate_evpid(uint32_t msgid) return evpid; } - -/**/ static const char* envelope_validate(struct envelope *ep) { diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c index 6bfb812e7ab..83928d0c1aa 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.55 2012/11/12 14:58:53 eric Exp $ */ +/* $OpenBSD: queue_fsqueue.c,v 1.56 2012/11/23 09:25:44 eric Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -46,6 +46,7 @@ static int fsqueue_envelope_create(uint64_t *, char *, size_t); static int fsqueue_envelope_load(uint64_t, char *, size_t); static int fsqueue_envelope_update(uint64_t, char *, size_t); static int fsqueue_envelope_delete(uint64_t); +static int fsqueue_envelope_walk(uint64_t *, char *, size_t); static int fsqueue_message_create(uint32_t *); static int fsqueue_message_commit(uint32_t); @@ -61,7 +62,7 @@ static int fsqueue_init(int); static int fsqueue_message(enum queue_op, uint32_t *); static int fsqueue_envelope(enum queue_op , uint64_t *, char *, size_t); -static void *fsqueue_qwalk_new(uint32_t); +static void *fsqueue_qwalk_new(void); static int fsqueue_qwalk(void *, uint64_t *); static void fsqueue_qwalk_close(void *); @@ -71,12 +72,9 @@ static void fsqueue_qwalk_close(void *); #define PATH_EVPTMP PATH_INCOMING "/envelope.tmp" struct queue_backend queue_backend_fs = { - fsqueue_init, - fsqueue_message, - fsqueue_envelope, - fsqueue_qwalk_new, - fsqueue_qwalk, - fsqueue_qwalk_close + fsqueue_init, + fsqueue_message, + fsqueue_envelope, }; static struct timespec startup; @@ -179,7 +177,8 @@ fsqueue_envelope_create(uint64_t *evpid, char *buf, size_t len) if (queued) fsqueue_envelope_path(*evpid, path, sizeof(path)); else - queue_envelope_incoming_path(*evpid, path, sizeof(path)); + queue_envelope_incoming_path(*evpid, path, + sizeof(path)); if (stat(path, &sb) == -1 && errno == ENOENT) goto found; @@ -242,6 +241,26 @@ fsqueue_envelope_delete(uint64_t evpid) } static int +fsqueue_envelope_walk(uint64_t *evpid, char *buf, size_t len) +{ + static int done = 0; + static void *hdl = NULL; + + if (done) + return (-1); + + if (hdl == NULL) + hdl = fsqueue_qwalk_new(); + + if (fsqueue_qwalk(hdl, evpid)) + return (fsqueue_envelope_load(*evpid, buf, len)); + + fsqueue_qwalk_close(hdl); + done = 1; + return (-1); +} + +static int fsqueue_message_create(uint32_t *msgid) { char rootdir[MAXPATHLEN]; @@ -250,7 +269,7 @@ fsqueue_message_create(uint32_t *msgid) again: *msgid = queue_generate_msgid(); - + /* prevent possible collision later when moving to Q_QUEUE */ fsqueue_message_path(*msgid, rootdir, sizeof(rootdir)); if (stat(rootdir, &sb) != -1 || errno != ENOENT) @@ -350,11 +369,13 @@ fsqueue_message_corrupt(uint32_t msgid) int retry = 0; fsqueue_message_path(msgid, rootdir, sizeof(rootdir)); - fsqueue_message_corrupt_path(msgid, corruptdir, sizeof(corruptdir)); + fsqueue_message_corrupt_path(msgid, corruptdir, + sizeof(corruptdir)); again: if (stat(corruptdir, &sb) != -1 || errno != ENOENT) { - fsqueue_message_corrupt_path(msgid, corruptdir, sizeof(corruptdir)); + fsqueue_message_corrupt_path(msgid, corruptdir, + sizeof(corruptdir)); snprintf(buf, sizeof(buf), ".%i", retry++); strlcat(corruptdir, buf, sizeof(corruptdir)); goto again; @@ -398,67 +419,56 @@ fsqueue_init(int server) static int fsqueue_message(enum queue_op qop, uint32_t *msgid) { - switch (qop) { - case QOP_CREATE: + switch (qop) { + case QOP_CREATE: return fsqueue_message_create(msgid); - - case QOP_DELETE: + case QOP_DELETE: return fsqueue_message_delete(*msgid); - - case QOP_COMMIT: + case QOP_COMMIT: return fsqueue_message_commit(*msgid); - - case QOP_FD_R: - return fsqueue_message_fd_r(*msgid); - + case QOP_FD_R: + return fsqueue_message_fd_r(*msgid); case QOP_CORRUPT: return fsqueue_message_corrupt(*msgid); - - default: + default: fatalx("queue_fsqueue_message: unsupported operation."); - } - + } return 0; } static int fsqueue_envelope(enum queue_op qop, uint64_t *evpid, char *buf, size_t len) { - switch (qop) { - case QOP_CREATE: + switch (qop) { + case QOP_CREATE: return fsqueue_envelope_create(evpid, buf, len); - - case QOP_DELETE: + case QOP_DELETE: return fsqueue_envelope_delete(*evpid); - - case QOP_LOAD: + case QOP_LOAD: return fsqueue_envelope_load(*evpid, buf, len); - - case QOP_UPDATE: + case QOP_UPDATE: return fsqueue_envelope_update(*evpid, buf, len); - - default: + case QOP_WALK: + return fsqueue_envelope_walk(evpid, buf, len); + default: fatalx("queue_fsqueue_envelope: unsupported operation."); - } - + } return 0; } struct qwalk { FTS *fts; - uint32_t msgid; int depth; }; static void * -fsqueue_qwalk_new(uint32_t msgid) +fsqueue_qwalk_new(void) { char path[MAXPATHLEN]; char * const path_argv[] = { path, NULL }; struct qwalk *q; q = xcalloc(1, sizeof(*q), "fsqueue_qwalk_new"); - q->msgid = msgid; strlcpy(path, PATH_QUEUE, sizeof(path)); q->fts = fts_open(path_argv, FTS_PHYSICAL | FTS_NOCHDIR, NULL); @@ -483,13 +493,11 @@ static int fsqueue_qwalk(void *hdl, uint64_t *evpid) { struct qwalk *q = hdl; - FTSENT *e; + FTSENT *e; char *tmp; - uint32_t msgid; - while ((e = fts_read(q->fts)) != NULL) { - - switch(e->fts_info) { + while ((e = fts_read(q->fts)) != NULL) { + switch (e->fts_info) { case FTS_D: q->depth += 1; if (q->depth == 2 && e->fts_namelen != 2) { @@ -504,14 +512,6 @@ fsqueue_qwalk(void *hdl, uint64_t *evpid) fts_set(q->fts, e, FTS_SKIP); break; } - if (q->msgid && (q->depth == 2 || q->depth == 3)) { - msgid = strtoull(e->fts_name, &tmp, 16); - if (msgid != (q->depth == 1) ? - (q->msgid & 0xff) : q->msgid) { - fts_set(q->fts, e, FTS_SKIP); - break; - } - } break; case FTS_DP: @@ -538,5 +538,5 @@ fsqueue_qwalk(void *hdl, uint64_t *evpid) } } - return (0); + return (0); } diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index 3ecf6c54ec1..aa063e1f1f3 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.97 2012/11/20 09:47:46 eric Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.98 2012/11/23 09:25:44 eric Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -520,27 +520,19 @@ show_stats_output(void) static void show_queue(int flags) { - struct qwalk *q; struct envelope envelope; - uint64_t evpid; + int r; log_init(1); if (chroot(PATH_SPOOL) == -1 || chdir(".") == -1) err(1, "%s", PATH_SPOOL); - q = qwalk_new(0); - - while (qwalk(q, &evpid)) { - if (! queue_envelope_load(evpid, &envelope)) - continue; - show_queue_envelope(&envelope, flags); - } - - qwalk_close(q); + while ((r = queue_envelope_walk(&envelope)) != -1) + if (r) + show_queue_envelope(&envelope, flags); } - static void show_queue_envelope(struct envelope *e, int online) { diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index fbc1d230baf..be97fb46936 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.396 2012/11/20 09:47:46 eric Exp $ */ +/* $OpenBSD: smtpd.h,v 1.397 2012/11/23 09:25:44 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -32,7 +32,7 @@ #define MAX_NAME_SIZE 64 #define MAX_HOPS_COUNT 100 -#define DEFAULT_MAX_BODY_SIZE (35*1024*1024) +#define DEFAULT_MAX_BODY_SIZE (35*1024*1024) #define MAX_TAG_SIZE 32 @@ -46,7 +46,7 @@ #define SMTPD_QUEUE_MAXINTERVAL (4 * 60 * 60) #define SMTPD_QUEUE_EXPIRY (4 * 24 * 60 * 60) #define SMTPD_USER "_smtpd" -#define SMTPD_FILTER_USER "_smtpmfa" +#define SMTPD_FILTER_USER "_smtpmfa" #define SMTPD_SOCKET "/var/run/smtpd.sock" #define SMTPD_BANNER "220 %s ESMTP OpenSMTPD" #define SMTPD_SESSION_TIMEOUT 300 @@ -74,12 +74,12 @@ /* max len of any smtp line */ #define SMTP_LINE_MAX MAX_LINE_SIZE -#define F_STARTTLS 0x01 -#define F_SMTPS 0x02 -#define F_AUTH 0x04 -#define F_SSL (F_SMTPS|F_STARTTLS) -#define F_STARTTLS_REQUIRE 0x08 -#define F_AUTH_REQUIRE 0x10 +#define F_STARTTLS 0x01 +#define F_SMTPS 0x02 +#define F_AUTH 0x04 +#define F_SSL (F_SMTPS|F_STARTTLS) +#define F_STARTTLS_REQUIRE 0x08 +#define F_AUTH_REQUIRE 0x10 #define F_BACKUP 0x20 /* XXX - MUST BE SYNC-ED WITH ROUTE_BACKUP */ @@ -136,10 +136,10 @@ enum imsg_type { IMSG_MDA_DONE, IMSG_MFA_CONNECT, - IMSG_MFA_HELO, - IMSG_MFA_MAIL, - IMSG_MFA_RCPT, - IMSG_MFA_DATALINE, + IMSG_MFA_HELO, + IMSG_MFA_MAIL, + IMSG_MFA_RCPT, + IMSG_MFA_DATALINE, IMSG_MFA_QUIT, IMSG_MFA_CLOSE, IMSG_MFA_RSET, @@ -303,21 +303,21 @@ enum decision { }; struct rule { - TAILQ_ENTRY(rule) r_entry; - enum decision r_decision; - char r_tag[MAX_TAG_SIZE]; - int r_accept; - struct map *r_sources; - struct cond r_condition; - enum action_type r_action; + TAILQ_ENTRY(rule) r_entry; + enum decision r_decision; + char r_tag[MAX_TAG_SIZE]; + int r_accept; + struct map *r_sources; + struct cond r_condition; + enum action_type r_action; union rule_dest { - char buffer[MAX_RULEBUFFER_LEN]; - struct relayhost relayhost; - } r_value; + char buffer[MAX_RULEBUFFER_LEN]; + struct relayhost relayhost; + } r_value; - struct mailaddr *r_as; - objid_t r_amap; - time_t r_qexpire; + struct mailaddr *r_as; + objid_t r_amap; + time_t r_qexpire; }; struct mailaddr { @@ -342,6 +342,7 @@ enum delivery_flags { DF_INTERNAL = 0x8, /* internal expansion forward */ /* runstate, not saved on disk */ + DF_PENDING = 0x10, DF_INFLIGHT = 0x20, }; @@ -366,23 +367,23 @@ enum expand_type { }; struct expandnode { - RB_ENTRY(expandnode) entry; - TAILQ_ENTRY(expandnode) tq_entry; - enum expand_type type; - int sameuser; - int alias; - struct rule *rule; - struct expandnode *parent; - unsigned int depth; + RB_ENTRY(expandnode) entry; + TAILQ_ENTRY(expandnode) tq_entry; + enum expand_type type; + int sameuser; + int alias; + struct rule *rule; + struct expandnode *parent; + unsigned int depth; union { /* * user field handles both expansion user and system user * so we MUST make it large enough to fit a mailaddr user */ - char user[MAX_LOCALPART_SIZE]; - char buffer[MAX_RULEBUFFER_LEN]; - struct mailaddr mailaddr; - } u; + char user[MAX_LOCALPART_SIZE]; + char buffer[MAX_RULEBUFFER_LEN]; + struct mailaddr mailaddr; + } u; }; struct expand { @@ -557,39 +558,38 @@ struct session { struct smtpd { - char sc_conffile[MAXPATHLEN]; - size_t sc_maxsize; - -#define SMTPD_OPT_VERBOSE 0x00000001 -#define SMTPD_OPT_NOACTION 0x00000002 - uint32_t sc_opts; -#define SMTPD_CONFIGURING 0x00000001 -#define SMTPD_EXITING 0x00000002 -#define SMTPD_MDA_PAUSED 0x00000004 -#define SMTPD_MTA_PAUSED 0x00000008 -#define SMTPD_SMTP_PAUSED 0x00000010 -#define SMTPD_MDA_BUSY 0x00000020 -#define SMTPD_MTA_BUSY 0x00000040 -#define SMTPD_BOUNCE_BUSY 0x00000080 -#define SMTPD_SMTP_DISABLED 0x00000100 - uint32_t sc_flags; - uint32_t sc_queue_flags; -#define QUEUE_COMPRESS 0x00000001 - char *sc_queue_compress_algo; - int sc_qexpire; - struct event sc_ev; - int *sc_pipes[PROC_COUNT] - [PROC_COUNT]; - struct imsgev *sc_ievs[PROC_COUNT]; - int sc_instances[PROC_COUNT]; - int sc_instance; - char *sc_title[PROC_COUNT]; - struct passwd *sc_pw; - char sc_hostname[MAXHOSTNAMELEN]; - struct queue_backend *sc_queue; - struct compress_backend *sc_compress; - struct scheduler_backend *sc_scheduler; - struct stat_backend *sc_stat; + char sc_conffile[MAXPATHLEN]; + size_t sc_maxsize; + +#define SMTPD_OPT_VERBOSE 0x00000001 +#define SMTPD_OPT_NOACTION 0x00000002 + uint32_t sc_opts; +#define SMTPD_CONFIGURING 0x00000001 +#define SMTPD_EXITING 0x00000002 +#define SMTPD_MDA_PAUSED 0x00000004 +#define SMTPD_MTA_PAUSED 0x00000008 +#define SMTPD_SMTP_PAUSED 0x00000010 +#define SMTPD_MDA_BUSY 0x00000020 +#define SMTPD_MTA_BUSY 0x00000040 +#define SMTPD_BOUNCE_BUSY 0x00000080 +#define SMTPD_SMTP_DISABLED 0x00000100 + uint32_t sc_flags; + uint32_t sc_queue_flags; +#define QUEUE_COMPRESS 0x00000001 + char *sc_queue_compress_algo; + int sc_qexpire; + struct event sc_ev; + int *sc_pipes[PROC_COUNT][PROC_COUNT]; + struct imsgev *sc_ievs[PROC_COUNT]; + int sc_instances[PROC_COUNT]; + int sc_instance; + char *sc_title[PROC_COUNT]; + struct passwd *sc_pw; + char sc_hostname[MAXHOSTNAMELEN]; + struct queue_backend *sc_queue; + struct compress_backend *sc_compress; + struct scheduler_backend *sc_scheduler; + struct stat_backend *sc_stat; time_t sc_uptime; @@ -757,10 +757,10 @@ struct map_netaddr { }; enum queue_op { - QOP_INVALID=0, QOP_CREATE, QOP_DELETE, QOP_UPDATE, + QOP_WALK, QOP_COMMIT, QOP_LOAD, QOP_FD_R, @@ -768,13 +768,9 @@ enum queue_op { }; struct queue_backend { - int (*init)(int); - int (*message)(enum queue_op, uint32_t *); - int (*envelope)(enum queue_op, uint64_t *, char *, size_t); - - void *(*qwalk_new)(uint32_t); - int (*qwalk)(void *, uint64_t *); - void (*qwalk_close)(void *); + int (*init)(int); + int (*message)(enum queue_op, uint32_t *); + int (*envelope)(enum queue_op, uint64_t *, char *, size_t); }; struct compress_backend { @@ -791,7 +787,7 @@ enum auth_type { }; struct auth_backend { - int (*authenticate)(char *, char *); + int (*authenticate)(char *, char *); }; @@ -816,8 +812,8 @@ struct user_backend { /* delivery_backend */ struct delivery_backend { - int allow_root; - void (*open)(struct deliver *); + int allow_root; + void (*open)(struct deliver *); }; struct evpstate { @@ -990,6 +986,7 @@ int envelope_ascii_dump(enum envelope_field, struct envelope *, char *, size_t); int envelope_load_buffer(struct envelope *, char *, size_t); int envelope_dump_buffer(struct envelope *, char *, size_t); + /* expand.c */ int expand_cmp(struct expandnode *, struct expandnode *); void expand_insert(struct expand *, struct expandnode *); @@ -997,6 +994,7 @@ struct expandnode *expand_lookup(struct expand *, struct expandnode *); void expand_free(struct expand *); RB_PROTOTYPE(expandtree, expandnode, nodes, expand_cmp); + /* forward.c */ int forwards_get(int, struct expand *); @@ -1004,15 +1002,16 @@ int forwards_get(int, struct expand *); /* lka.c */ pid_t lka(void); + /* lka_session.c */ void lka_session(struct submit_status *); void lka_session_forward_reply(struct forward_req *, int); + /* map.c */ void *map_open(struct map *); void map_update(struct map *); void map_close(struct map *, void *); - void *map_lookup(objid_t, const char *, enum map_kind); int map_compare(objid_t, const char *, enum map_kind, int (*)(const char *, const char *)); @@ -1048,17 +1047,21 @@ void mta_route_error(struct mta_route *, const char *); void mta_route_collect(struct mta_route *); const char *mta_route_to_text(struct mta_route *); + /* mta_session.c */ void mta_session(struct mta_route *); void mta_session_imsg(struct imsgev *, struct imsg *); + /* parse.y */ int parse_config(struct smtpd *, const char *, int); int cmdline_symset(char *); + /* queue.c */ pid_t queue(void); + /* queue_backend.c */ uint32_t queue_generate_msgid(void); uint64_t queue_generate_evpid(uint32_t msgid); @@ -1076,9 +1079,8 @@ int queue_envelope_create(struct envelope *); int queue_envelope_delete(struct envelope *); int queue_envelope_load(uint64_t, struct envelope *); int queue_envelope_update(struct envelope *); -void *qwalk_new(uint32_t); -int qwalk(void *, uint64_t *); -void qwalk_close(void *); +int queue_envelope_walk(struct envelope *); + /* compress_backend.c */ struct compress_backend *compress_backend_lookup(const char *); @@ -1095,16 +1097,19 @@ struct rule *ruleset_match(const struct envelope *); /* scheduler.c */ pid_t scheduler(void); + /* scheduler_bakend.c */ struct scheduler_backend *scheduler_backend_lookup(const char *); void scheduler_info(struct scheduler_info *, struct envelope *); time_t scheduler_compute_schedule(struct scheduler_info *); + /* smtp.c */ pid_t smtp(void); void smtp_resume(void); void smtp_destroy(struct session *); + /* smtp_session.c */ void session_init(struct listener *, struct session *); int session_cmp(struct session *, struct session *); @@ -1112,8 +1117,7 @@ void session_io(struct io *, int); void session_pickup(struct session *, struct submit_status *); void session_destroy(struct session *, const char *); void session_respond(struct session *, char *, ...) - __attribute__ ((format (printf, 2, 3))); - + __attribute__((format (printf, 2, 3))); SPLAY_PROTOTYPE(sessiontree, session, s_nodes, session_cmp); @@ -1147,7 +1151,6 @@ struct stat_backend *stat_backend_lookup(const char *); void stat_increment(const char *, size_t); void stat_decrement(const char *, size_t); void stat_set(const char *, const struct stat_value *); - struct stat_value *stat_counter(size_t); struct stat_value *stat_timestamp(time_t); struct stat_value *stat_timeval(struct timeval *); @@ -1186,7 +1189,7 @@ struct arglist { void addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3))); int bsnprintf(char *, size_t, const char *, ...) - __attribute__ ((format (printf, 3, 4))); + __attribute__((format (printf, 3, 4))); int mkdirs(char *, mode_t); int safe_fclose(FILE *); int hostname_match(const char *, const char *); @@ -1225,6 +1228,7 @@ void session_socket_no_linger(int); int session_socket_error(int); uint64_t strtoevpid(const char *); + /* waitq.c */ int waitq_wait(void *, void (*)(void *, void *, void *), void *); void waitq_run(void *, void *); |