diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/queue.c | 35 | ||||
-rw-r--r-- | usr.sbin/smtpd/runner.c | 8 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 3 |
4 files changed, 20 insertions, 31 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index dd37bcaa1f6..d2447973f28 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.31 2008/12/18 15:11:21 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.32 2008/12/27 17:03:29 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -62,7 +62,6 @@ 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 *); -u_int16_t queue_message_hash(struct message *); int queue_record_incoming_envelope(struct message *); int queue_update_incoming_envelope(struct message *); int queue_remove_incoming_envelope(struct message *); @@ -78,7 +77,6 @@ int queue_load_envelope(struct message *, char *); void queue_delete_message(char *); void batch_send(struct smtpd *, struct batch *, time_t); -u_int32_t hash(u_int8_t *, size_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); @@ -930,7 +928,7 @@ queue_commit_incoming_message(struct message *messagep) messagep->message_id)) fatal("queue_commit_message_incoming: snprintf"); - hval = queue_message_hash(messagep); + hval = queue_hash(messagep->message_id); if (! bsnprintf(queuedir, MAXPATHLEN, "%s/%d", PATH_QUEUE, hval)) fatal("queue_commit_message_incoming: snprintf"); @@ -983,7 +981,7 @@ queue_record_envelope(struct message *messagep) messagep->message_id)) fatal("queue_record_envelope: snprintf"); - hval = queue_message_hash(messagep); + hval = queue_hash(messagep->message_id); if (! bsnprintf(queuedir, MAXPATHLEN, "%s/%d", PATH_QUEUE, hval)) fatal("queue_record_envelope: snprintf"); @@ -1041,7 +1039,7 @@ queue_remove_envelope(struct message *messagep) char pathname[MAXPATHLEN]; u_int16_t hval; - hval = queue_message_hash(messagep); + hval = queue_hash(messagep->message_id); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, hval, messagep->message_id, PATH_ENVELOPES, @@ -1070,7 +1068,7 @@ queue_update_envelope(struct message *messagep) mode_t mode = O_RDWR; u_int16_t hval; - hval = queue_message_hash(messagep); + hval = queue_hash(messagep->message_id); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, hval, messagep->message_id, PATH_ENVELOPES, messagep->message_uid)) @@ -1106,7 +1104,7 @@ queue_load_envelope(struct message *messagep, char *evpid) strlcpy(msgid, evpid, MAXPATHLEN); *strrchr(msgid, '.') = '\0'; - hval = hash(msgid, strlen(msgid)) % DIRHASH_BUCKETS; + hval = queue_hash(msgid); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, hval, msgid, PATH_ENVELOPES, evpid)) return 0; @@ -1131,7 +1129,7 @@ queue_open_message_file(struct batch *batchp) mode_t mode = O_RDONLY; u_int16_t hval; - hval = hash(batchp->message_id, strlen(batchp->message_id)) % DIRHASH_BUCKETS; + hval = queue_hash(batchp->message_id); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s/message", PATH_QUEUE, hval, batchp->message_id)) @@ -1151,7 +1149,7 @@ queue_delete_message(char *msgid) char msgpath[MAXPATHLEN]; u_int16_t hval; - hval = hash(msgid, strlen(msgid)) % DIRHASH_BUCKETS; + hval = queue_hash(msgid); if (! bsnprintf(rootdir, MAXPATHLEN, "%s/%d/%s", PATH_QUEUE, hval, msgid)) fatal("queue_delete_message: snprintf"); @@ -1185,19 +1183,12 @@ queue_delete_message(char *msgid) } u_int16_t -queue_message_hash(struct message *messagep) +queue_hash(char *msgid) { - return hash(messagep->message_id, strlen(messagep->message_id)) - % DIRHASH_BUCKETS; -} - -u_int32_t -hash(u_int8_t *buf, size_t len) -{ - u_int32_t h; + u_int16_t h; - for (h = 5381; len; len--) - h = ((h << 5) + h) + *buf++; + for (h = 5381; *msgid; msgid++) + h = ((h << 5) + h) + *msgid; - return h; + return (h % DIRHASH_BUCKETS); } diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c index cafedacd3cd..4557d9f141e 100644 --- a/usr.sbin/smtpd/runner.c +++ b/usr.sbin/smtpd/runner.c @@ -1,4 +1,4 @@ -/* $OpenBSD: runner.c,v 1.9 2008/12/19 00:39:05 gilles Exp $ */ +/* $OpenBSD: runner.c,v 1.10 2008/12/27 17:03:29 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -76,8 +76,6 @@ int queue_load_envelope(struct message *, char *); int queue_update_envelope(struct message *); int queue_remove_envelope(struct message *); -u_int32_t hash(u_int8_t *, size_t); - void runner_sig_handler(int sig, short event, void *p) { @@ -500,7 +498,7 @@ runner_process_message(struct smtpd *env, char *messageid) char evppath[MAXPATHLEN]; u_int16_t hval = 0; - hval = hash(messageid, strlen(messageid)) % DIRHASH_BUCKETS; + hval = queue_hash(messageid); if (! bsnprintf(evppath, MAXPATHLEN, "%s/%d/%s%s", PATH_QUEUE, hval, messageid, PATH_ENVELOPES)) @@ -548,7 +546,7 @@ runner_process_envelope(struct smtpd *env, char *msgid, char *evpid) message.flags |= F_MESSAGE_SCHEDULED; queue_update_envelope(&message); - hval = hash(msgid, strlen(msgid)) % DIRHASH_BUCKETS; + 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"); diff --git a/usr.sbin/smtpd/smtpd.c b/usr.sbin/smtpd/smtpd.c index 8226c3e7f42..273fff535f0 100644 --- a/usr.sbin/smtpd/smtpd.c +++ b/usr.sbin/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.c,v 1.19 2008/12/22 12:56:21 jacekm Exp $ */ +/* $OpenBSD: smtpd.c,v 1.20 2008/12/27 17:03:29 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -62,7 +62,6 @@ int parent_maildir_init(struct passwd *, char *); int parent_external_mda(struct batch *, struct path *); int check_child(pid_t, const char *); int setup_spool(uid_t, gid_t); -u_int16_t queue_message_hash(struct message *); pid_t lka_pid = 0; pid_t mfa_pid = 0; @@ -762,7 +761,7 @@ parent_open_message_file(struct batch *batchp) struct message *messagep; messagep = &batchp->message; - hval = queue_message_hash(messagep); + hval = queue_hash(messagep->message_id); if (! bsnprintf(pathname, MAXPATHLEN, "%s%s/%d/%s/message", PATH_SPOOL, PATH_QUEUE, hval, batchp->message_id)) { diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 3bf1347fd49..5913d5ecee5 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.35 2008/12/26 10:28:31 jacekm Exp $ */ +/* $OpenBSD: smtpd.h,v 1.36 2008/12/27 17:03:29 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -702,6 +702,7 @@ 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 */ pid_t mda(struct smtpd *); |