diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2007-01-04 21:41:38 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2007-01-04 21:41:38 +0000 |
commit | 1d88fc608533f55ea47a0978e4b19767327d9868 (patch) | |
tree | 289789c5193e3655f2c7a45e2f96cc42d3d660d7 /usr.sbin | |
parent | 9b6643396e32c30a97ef7a70fce259762fbdcbcd (diff) |
Using DB_BTREE for spamd is wrong, order is never required
and the rebalancing really slags big databases. Make spamd use DB_HASH
instead, and convert if the old type is noticed on startup.
Testing by me, djm, ian, others
ok deraadt@, millert@, djm@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/spamdb/spamdb.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/usr.sbin/spamdb/spamdb.c b/usr.sbin/spamdb/spamdb.c index e4028f3fd23..82648231b4b 100644 --- a/usr.sbin/spamdb/spamdb.c +++ b/usr.sbin/spamdb/spamdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamdb.c,v 1.18 2006/12/09 20:04:27 jmc Exp $ */ +/* $OpenBSD: spamdb.c,v 1.19 2007/01/04 21:41:37 beck Exp $ */ /* * Copyright (c) 2004 Bob Beck. All rights reserved. @@ -29,6 +29,7 @@ #include <time.h> #include <netdb.h> #include <ctype.h> +#include <errno.h> #include "grey.h" @@ -252,7 +253,7 @@ int main(int argc, char **argv) { int i, ch, action = 0, type = WHITE, r = 0; - BTREEINFO btreeinfo; + HASHINFO hashinfo; DB *db; while ((ch = getopt(argc, argv, "adtT")) != -1) { @@ -277,12 +278,17 @@ main(int argc, char **argv) argc -= optind; argv += optind; - memset(&btreeinfo, 0, sizeof(btreeinfo)); - btreeinfo.cachesize = 8192 * 128; - db = dbopen(PATH_SPAMD_DB, O_EXLOCK|O_RDWR, 0600, DB_BTREE, - &btreeinfo); - if (db == NULL) - err(1, "cannot open %s for writing", PATH_SPAMD_DB); + memset(&hashinfo, 0, sizeof(hashinfo)); + db = dbopen(PATH_SPAMD_DB, O_EXLOCK|O_RDWR, 0600, DB_HASH, + &hashinfo); + if (db == NULL) { + if (errno == EFTYPE) + err(1, + "%s is old, run current spamd to convert it", + PATH_SPAMD_DB); + else + err(1, "cannot open %s for writing", PATH_SPAMD_DB); + } switch (action) { case 0: |