diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2011-10-23 09:30:08 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2011-10-23 09:30:08 +0000 |
commit | e3cfbeb71221f3f3bee3fcbfef00515742b2db32 (patch) | |
tree | b6982699bd3a5aa673680f516988242d259225b7 /usr.sbin/smtpd/util.c | |
parent | 436e188d636566b43d727d0356572ecdff1c87d9 (diff) |
fsqueue no longer stores envelopes by dumping the structure, instead use a
couple of load/dump functions to convert to and from a human readable fmt.
while at it kill struct delivery and merge back its fields to the envelope.
this basically means we shouldn't require users to flush their queues every
time we make a change to struct envelope.
work is not done, but we're at a better state than the binary fsqueue so
we'll improve it in-tree.
has been running on my own box for the last 12 hours or so
ok eric@, chl@
Diffstat (limited to 'usr.sbin/smtpd/util.c')
-rw-r--r-- | usr.sbin/smtpd/util.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c index afa5eef128f..128a6275211 100644 --- a/usr.sbin/smtpd/util.c +++ b/usr.sbin/smtpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.47 2011/05/17 18:54:32 gilles Exp $ */ +/* $OpenBSD: util.c,v 1.48 2011/10/23 09:30:07 gilles Exp $ */ /* * Copyright (c) 2000,2001 Markus Friedl. All rights reserved. @@ -352,9 +352,9 @@ envelope_set_errormsg(struct envelope *e, char *fmt, ...) va_start(ap, fmt); - ret = vsnprintf(e->delivery.errorline, MAX_LINE_SIZE, fmt, ap); + ret = vsnprintf(e->errorline, MAX_LINE_SIZE, fmt, ap); if (ret >= MAX_LINE_SIZE) - strlcpy(e->delivery.errorline + (MAX_LINE_SIZE - 4), "...", 4); + strlcpy(e->errorline + (MAX_LINE_SIZE - 4), "...", 4); /* this should not happen */ if (ret == -1) @@ -366,7 +366,7 @@ envelope_set_errormsg(struct envelope *e, char *fmt, ...) char * envelope_get_errormsg(struct envelope *e) { - return e->delivery.errorline; + return e->errorline; } void @@ -547,6 +547,38 @@ filename_to_evpid(char *filename) } u_int32_t +msgid_generate(void) +{ + u_int32_t ret; + + do { + ret = arc4random(); + } while (ret == 0); + + log_debug("msgid_generate: %08x", ret); + + return ret; +} + +u_int64_t +evpid_generate(u_int32_t msgid) +{ + u_int64_t ret; + + ret = msgid; + log_debug("evpid_generate: %016llx", ret); + ret <<= 32; + log_debug("evpid_generate: %016llx", ret); + do { + ret |= arc4random(); + } while ((ret & 0xffffffff) == 0); + + log_debug("evpid_generate: %016llx", ret); + + return ret; +} + +u_int32_t evpid_to_msgid(u_int64_t evpid) { return (evpid >> 32); |