diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/queue.c | 32 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 45 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 8 |
3 files changed, 28 insertions, 57 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 2c43ddf473a..46f5155fcc4 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.33 2008/12/27 17:12:39 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.34 2008/12/27 17:36:37 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -53,34 +53,20 @@ void queue_dispatch_lka(int, short, void *); void queue_dispatch_runner(int, short, void *); void queue_setup_events(struct smtpd *); void queue_disable_events(struct smtpd *); -void queue_timeout(int, short, void *); void queue_purge_incoming(void); + int queue_create_incoming_layout(char *); -int queue_record_envelope(struct message *); -int queue_remove_envelope(struct message *); -int queue_open_message_file(struct batch *); -int queue_batch_resolved(struct smtpd *, struct batch *); -int queue_message_schedule(struct message *, time_t); -void queue_delete_message_file(char *); +void queue_delete_incoming_message(char *); int queue_record_incoming_envelope(struct message *); int queue_update_incoming_envelope(struct message *); int queue_remove_incoming_envelope(struct message *); int queue_commit_incoming_message(struct message *); -void queue_delete_incoming_message(char *); -int queue_update_envelope(struct message *); int queue_open_incoming_message_file(struct message *); -void queue_process(struct smtpd *); -int queue_process_bucket(struct smtpd *, u_int16_t); -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 *); -struct batch *batch_by_id(struct smtpd *, u_int64_t); -struct message *message_by_id(struct smtpd *, struct batch *, u_int64_t); +int queue_record_envelope(struct message *); +int queue_open_message_file(struct batch *); +void queue_delete_message(char *); void queue_sig_handler(int sig, short event, void *p) @@ -981,14 +967,14 @@ queue_remove_envelope(struct message *messagep) if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, hval, messagep->message_id, PATH_ENVELOPES, messagep->message_uid)) - fatal("queue_remove_incoming_envelope: snprintf"); + fatal("queue_remove_envelope: snprintf"); if (unlink(pathname) == -1) - fatal("queue_remove_incoming_envelope: unlink"); + fatal("queue_remove_envelope: unlink"); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s", PATH_QUEUE, hval, messagep->message_id, PATH_ENVELOPES)) - fatal("queue_remove_incoming_envelope: snprintf"); + fatal("queue_remove_envelope: snprintf"); if (rmdir(pathname) != -1) queue_delete_message(messagep->message_id); diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index 4557d9f141e..214f1ed85c5 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.10 2008/12/27 17:03:29 jacekm Exp $ */ +/* $OpenBSD: runner.c,v 1.11 2008/12/27 17:36:37 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -72,10 +72,6 @@ void runner_purge_message(char *); struct batch *batch_record(struct smtpd *, struct message *); struct batch *batch_lookup(struct smtpd *, struct message *); -int queue_load_envelope(struct message *, char *); -int queue_update_envelope(struct message *); -int queue_remove_envelope(struct message *); - void runner_sig_handler(int sig, short event, void *p) { @@ -444,21 +440,17 @@ runner_process_queue(struct smtpd *env) dirp = opendir(PATH_QUEUE); if (dirp == NULL) - fatal("queue_process: opendir"); - + fatal("runner_process_queue: opendir"); while ((dp = readdir(dirp)) != NULL) { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; - bucket = strtonum(dp->d_name, 0, DIRHASH_BUCKETS - 1, &errstr); if (errstr) { - log_warn("queue_process: %s/%s is not a valid bucket", + log_warn("runner_process_queue: invalid bucket: %s/%s", PATH_QUEUE, dp->d_name); continue; } - runner_process_bucket(env, bucket); } closedir(dirp); @@ -472,21 +464,16 @@ runner_process_bucket(struct smtpd *env, u_int16_t bucket) char bucketpath[MAXPATHLEN]; if (! bsnprintf(bucketpath, MAXPATHLEN, "%s/%d", PATH_QUEUE, bucket)) - fatal("queue_process_bucket: snprintf"); - + fatal("runner_process_bucket: snprintf"); dirp = opendir(bucketpath); if (dirp == NULL) return; - while ((dp = readdir(dirp)) != NULL) { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; - runner_process_message(env, dp->d_name); } - closedir(dirp); } @@ -496,27 +483,21 @@ runner_process_message(struct smtpd *env, char *messageid) DIR *dirp = NULL; struct dirent *dp; char evppath[MAXPATHLEN]; - u_int16_t hval = 0; + u_int16_t hval; hval = queue_hash(messageid); - if (! bsnprintf(evppath, MAXPATHLEN, "%s/%d/%s%s", PATH_QUEUE, hval, messageid, PATH_ENVELOPES)) - fatal("queue_process_message: snprintf"); - + fatal("runner_process_message: snprintf"); dirp = opendir(evppath); if (dirp == NULL) return; - while ((dp = readdir(dirp)) != NULL) { - if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; - runner_process_envelope(env, dp->d_name, dp->d_name); } - closedir(dirp); } @@ -549,14 +530,14 @@ runner_process_envelope(struct smtpd *env, char *msgid, char *evpid) hval = queue_hash(msgid); if (! bsnprintf(evppath, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, hval, msgid, PATH_ENVELOPES, evpid)) - fatal("queue_process_envelope: snprintf"); + fatal("runner_process_envelope: snprintf"); if (! bsnprintf(rqpath, MAXPATHLEN, "%s/%s", PATH_RUNQUEUE, evpid)) - fatal("queue_process_envelope: snprintf"); + fatal("runner_process_envelope: snprintf"); if (stat(rqpath, &sb) == -1) { if (errno != ENOENT) - fatal("queue_process_envelope: stat"); + fatal("runner_process_envelope: stat"); if (symlink(evppath, rqpath) == -1) { log_info("queue_process_envelope: " @@ -580,19 +561,19 @@ runner_process_runqueue(struct smtpd *env) dirp = opendir(PATH_RUNQUEUE); if (dirp == NULL) - fatal("queue_process_runqueue: opendir"); + fatal("runner_process_runqueue: opendir"); while ((dp = readdir(dirp)) != NULL) { if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; - snprintf(pathname, MAXPATHLEN, "%s/%s", PATH_RUNQUEUE, dp->d_name); + snprintf(pathname, MAXPATHLEN, "%s/%s", PATH_RUNQUEUE, + dp->d_name); unlink(pathname); - if (! queue_load_envelope(&message, dp->d_name)) { + if (! queue_load_envelope(&message, dp->d_name)) continue; - } if (message.flags & F_MESSAGE_PROCESSING) continue; diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 5913d5ecee5..fadadadadce 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.36 2008/12/27 17:03:29 jacekm Exp $ */ +/* $OpenBSD: smtpd.h,v 1.37 2008/12/27 17:36:37 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -698,10 +698,14 @@ SPLAY_PROTOTYPE(msgtree, message, nodes, msg_cmp); /* queue.c */ pid_t queue(struct smtpd *); u_int64_t queue_generate_id(void); +int queue_remove_batch_message(struct smtpd *, struct batch *, + struct message *); +int queue_load_envelope(struct message *, char *); +int queue_update_envelope(struct message *); +int queue_remove_envelope(struct message *); int batch_cmp(struct batch *, struct batch *); struct batch *batch_by_id(struct smtpd *, u_int64_t); struct message *message_by_id(struct smtpd *, struct batch *, u_int64_t); -int queue_remove_batch_message(struct smtpd *, struct batch *, struct message *); u_int16_t queue_hash(char *); /* mda.c */ |