summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2012-07-09 08:08:30 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2012-07-09 08:08:30 +0000
commit83c96f8a8411e34530e3406153405d0d63f36f7d (patch)
tree38c5d5ed89c1b7bb308ffd570e0fa4702c1957f0 /usr.sbin/smtpd
parent36597207628818a5b6e916c71cac6e2a8986ae9a (diff)
first step of simplifying fsqueue:
- remove the /envelopes subdirectory, envelopes are at the same level than the message file - kill PATH_ENVELOPES define - reduce the number of buckets from 0xfff to 0xff, this avoid performances of the queue to decrease when we start having tons of buckets this diff introduces a change to the queue layout, you will want to empty your queue before updating. more cleanup to come ok eric@, ok chl@
Diffstat (limited to 'usr.sbin/smtpd')
-rw-r--r--usr.sbin/smtpd/queue_backend.c5
-rw-r--r--usr.sbin/smtpd/queue_fsqueue.c54
-rw-r--r--usr.sbin/smtpd/runner.c4
-rw-r--r--usr.sbin/smtpd/smtpd.h3
4 files changed, 24 insertions, 42 deletions
diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c
index b817075b06b..f5bfeabea9f 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.26 2012/07/08 18:13:08 chl Exp $ */
+/* $OpenBSD: queue_backend.c,v 1.27 2012/07/09 08:08:29 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -54,10 +54,9 @@ 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%s/%016" PRIx64,
+ return bsnprintf(buf, len, "%s/%08x/%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 f498fbf71aa..0a27c1688b9 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.44 2012/07/08 18:13:08 chl Exp $ */
+/* $OpenBSD: queue_fsqueue.c,v 1.45 2012/07/09 08:08:29 gilles Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -81,9 +81,9 @@ struct queue_backend queue_backend_fs = {
static int
fsqueue_message_path(uint32_t msgid, char *buf, size_t len)
{
- return bsnprintf(buf, len, "%s/%03x/%08x",
+ return bsnprintf(buf, len, "%s/%02x/%08x",
PATH_QUEUE,
- msgid & 0xfff,
+ msgid & 0xff,
msgid);
}
@@ -98,11 +98,10 @@ 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/%03x/%08x%s/%016" PRIx64,
+ return bsnprintf(buf, len, "%s/%02x/%08x/%016" PRIx64,
PATH_QUEUE,
- evpid_to_msgid(evpid) & 0xfff,
- evpid_to_msgid(evpid),
- PATH_ENVELOPES, evpid);
+ evpid_to_msgid(evpid) & 0xff,
+ evpid_to_msgid(evpid), evpid);
}
static int
@@ -207,20 +206,18 @@ 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) {
- log_debug("######: %s [errno: %d]", pathname, errno);
+ if (unlink(pathname) == -1)
fatal("fsqueue_envelope_delete: unlink");
- }
*strrchr(pathname, '/') = '\0';
- if (rmdir(pathname) != -1)
- fsqueue_message_delete(evpid_to_msgid(ep->id));
+ if (stat(pathname, &sb) != -1)
+ if (sb.st_nlink == 2)
+ fsqueue_message_delete(evpid_to_msgid(ep->id));
return 1;
}
@@ -229,7 +226,6 @@ static int
fsqueue_message_create(u_int32_t *msgid)
{
char rootdir[MAXPATHLEN];
- char evpdir[MAXPATHLEN];
struct stat sb;
again:
@@ -251,19 +247,6 @@ 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;
}
@@ -454,10 +437,10 @@ fsqueue_qwalk_new(u_int32_t msgid)
if (q->msgid) {
/* force level and bucket */
- q->bucket = q->msgid & 0xfff;
+ q->bucket = q->msgid & 0xff;
q->level = 2;
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%03x/%08x/%s",
- PATH_QUEUE, q->bucket, q->msgid, PATH_ENVELOPES))
+ if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%08x/",
+ PATH_QUEUE, q->bucket, q->msgid))
fatalx("walk_queue: snprintf");
}
q->filefn = walk_queue;
@@ -558,14 +541,13 @@ walk_queue(struct qwalk *q, char *fname)
log_warnx("walk_queue: invalid bucket: %s", fname);
return (QWALK_AGAIN);
}
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%03x",
- PATH_QUEUE, q->bucket & 0xfff))
+ if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x",
+ PATH_QUEUE, q->bucket & 0xff))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);
case 1:
- if (! bsnprintf(q->path, sizeof(q->path), "%s/%03x/%s%s",
- PATH_QUEUE, q->bucket & 0xfff, fname,
- PATH_ENVELOPES))
+ if (! bsnprintf(q->path, sizeof(q->path), "%s/%02x/%s",
+ PATH_QUEUE, q->bucket & 0xff, fname))
fatalx("walk_queue: snprintf");
return (QWALK_RECURSE);
case 2:
diff --git a/usr.sbin/smtpd/runner.c b/usr.sbin/smtpd/runner.c
index 0f825e656ad..6c4e0644e50 100644
--- a/usr.sbin/smtpd/runner.c
+++ b/usr.sbin/smtpd/runner.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: runner.c,v 1.143 2012/07/08 18:13:08 chl Exp $ */
+/* $OpenBSD: runner.c,v 1.144 2012/07/09 08:08:29 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -306,8 +306,10 @@ runner_timeout(int fd, short event, void *p)
nsched = 0;
again:
+/*
if (scheduler->display)
scheduler->display();
+*/
curtm = time(NULL);
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index c15cf9498f4..e279059de48 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.303 2012/07/08 18:13:08 chl Exp $ */
+/* $OpenBSD: smtpd.h,v 1.304 2012/07/09 08:08:29 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -68,7 +68,6 @@
#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 */