diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-07-10 23:21:35 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-07-10 23:21:35 +0000 |
commit | ff88c5144b8e7001a5050403af9de57f7538d5c6 (patch) | |
tree | e6caa19a16fc9286332fdb8af4469531b8ac5025 /usr.sbin | |
parent | 191d5963c899294598e421fab9182a6da4f16ee0 (diff) |
backout the:
- remove the /envelopes subdirectory, envelopes are at the same level than
the message file
- kill PATH_ENVELOPES define
but keep the:
- reduce the number of buckets from 0xfff to 0xff, this avoid performances
of the queue to decrease when we start having tons of buckets
ok eric@ gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/queue_backend.c | 5 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue_fsqueue.c | 42 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 3 |
3 files changed, 35 insertions, 15 deletions
diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index f5bfeabea9f..bfb5587d0d9 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.27 2012/07/09 08:08:29 gilles Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.28 2012/07/10 23:21:34 chl Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -54,9 +54,10 @@ queue_message_incoming_path(u_int32_t msgid, char *buf, size_t len) int queue_envelope_incoming_path(u_int64_t evpid, char *buf, size_t len) { - return bsnprintf(buf, len, "%s/%08x/%016" PRIx64, + return bsnprintf(buf, len, "%s/%08x%s/%016" PRIx64, PATH_INCOMING, evpid_to_msgid(evpid), + PATH_ENVELOPES, evpid); } diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c index 0a27c1688b9..0271d5667cf 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.45 2012/07/09 08:08:29 gilles Exp $ */ +/* $OpenBSD: queue_fsqueue.c,v 1.46 2012/07/10 23:21:34 chl Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -98,10 +98,11 @@ fsqueue_message_corrupt_path(uint32_t msgid, char *buf, size_t len) static int fsqueue_envelope_path(uint64_t evpid, char *buf, size_t len) { - return bsnprintf(buf, len, "%s/%02x/%08x/%016" PRIx64, + return bsnprintf(buf, len, "%s/%02x/%08x%s/%016" PRIx64, PATH_QUEUE, evpid_to_msgid(evpid) & 0xff, - evpid_to_msgid(evpid), evpid); + evpid_to_msgid(evpid), + PATH_ENVELOPES, evpid); } static int @@ -206,18 +207,20 @@ static int fsqueue_envelope_delete(struct envelope *ep) { char pathname[MAXPATHLEN]; - struct stat sb; + log_debug("#### %s: queue_envelope_delete: %016" PRIx64, + __func__, ep->id); fsqueue_envelope_path(ep->id, pathname, sizeof(pathname)); - if (unlink(pathname) == -1) + if (unlink(pathname) == -1) { + log_debug("######: %s [errno: %d]", pathname, errno); fatal("fsqueue_envelope_delete: unlink"); + } *strrchr(pathname, '/') = '\0'; - if (stat(pathname, &sb) != -1) - if (sb.st_nlink == 2) - fsqueue_message_delete(evpid_to_msgid(ep->id)); + if (rmdir(pathname) != -1) + fsqueue_message_delete(evpid_to_msgid(ep->id)); return 1; } @@ -226,6 +229,7 @@ static int fsqueue_message_create(u_int32_t *msgid) { char rootdir[MAXPATHLEN]; + char evpdir[MAXPATHLEN]; struct stat sb; again: @@ -247,6 +251,19 @@ again: } fatal("fsqueue_message_create: mkdir"); } + + strlcpy(evpdir, rootdir, sizeof(evpdir)); + strlcat(evpdir, PATH_ENVELOPES, sizeof(evpdir)); + + if (mkdir(evpdir, 0700) == -1) { + if (errno == ENOSPC) { + rmdir(rootdir); + *msgid = 0; + return 0; + } + fatal("fsqueue_message_create: mkdir"); + } + return 1; } @@ -439,8 +456,8 @@ fsqueue_qwalk_new(u_int32_t msgid) /* force level and bucket */ q->bucket = q->msgid & 0xff; q->level = 2; - if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%08x/", - PATH_QUEUE, q->bucket, q->msgid)) + if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%08x%s", + PATH_QUEUE, q->bucket, q->msgid, PATH_ENVELOPES)) fatalx("walk_queue: snprintf"); } q->filefn = walk_queue; @@ -546,8 +563,9 @@ walk_queue(struct qwalk *q, char *fname) fatalx("walk_queue: snprintf"); return (QWALK_RECURSE); case 1: - if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%s", - PATH_QUEUE, q->bucket & 0xff, fname)) + if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%s%s", + PATH_QUEUE, q->bucket & 0xff, fname, + PATH_ENVELOPES)) fatalx("walk_queue: snprintf"); return (QWALK_RECURSE); case 2: diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 0a7fe4d0067..d900a833544 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.308 2012/07/10 16:11:43 chl Exp $ */ +/* $OpenBSD: smtpd.h,v 1.309 2012/07/10 23:21:34 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -68,6 +68,7 @@ #define PATH_OFFLINE "/offline" #define PATH_PURGE "/purge" #define PATH_INCOMING "/incoming" +#define PATH_ENVELOPES "/envelopes" #define PATH_MESSAGE "/message" /* number of MX records to lookup */ |