summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/queue_backend.c
diff options
context:
space:
mode:
authorCharles Longeau <chl@cvs.openbsd.org>2012-08-24 13:13:14 +0000
committerCharles Longeau <chl@cvs.openbsd.org>2012-08-24 13:13:14 +0000
commit4aa47bf1d14daa7ee4fd7ee9247d141efb7d5f44 (patch)
tree75198df279c5dba6abad7ef7b57586781c5f86f4 /usr.sbin/smtpd/queue_backend.c
parentedde4e56780201577a2072e058954d2586c75d4b (diff)
Don't pass struct envelope pointer in queue backend API, instead use envelope id and
an envelope ascii buffer. ok eric@ gilles@
Diffstat (limited to 'usr.sbin/smtpd/queue_backend.c')
-rw-r--r--usr.sbin/smtpd/queue_backend.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c
index a81ef220936..c0a0f68d982 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.29 2012/08/19 14:16:58 chl Exp $ */
+/* $OpenBSD: queue_backend.c,v 1.30 2012/08/24 13:13:13 chl Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -125,13 +125,32 @@ queue_message_fd_rw(uint32_t msgid)
return open(msgpath, O_RDWR | O_CREAT | O_EXCL, 0600);
}
+static int
+queue_envelope_dump_buffer(struct envelope *ep, char *evpbuf, size_t evpbufsize)
+{
+ return (envelope_dump_buffer(ep, evpbuf, evpbufsize));
+}
+
+static int
+queue_envelope_load_buffer(struct envelope *ep, char *evpbuf, size_t evpbufsize)
+{
+ return (envelope_load_buffer(ep, evpbuf, evpbufsize));
+}
+
+
int
queue_envelope_create(struct envelope *ep)
{
- int r;
+ int r;
+ char evpbuf[sizeof(struct envelope)];
+ size_t evplen;
ep->creation = time(NULL);
- r = env->sc_queue->envelope(QOP_CREATE, ep);
+ evplen = queue_envelope_dump_buffer(ep, evpbuf, sizeof evpbuf);
+ if (evplen == 0)
+ return (0);
+
+ r = env->sc_queue->envelope(QOP_CREATE, &ep->id, evpbuf, evplen);
if (!r) {
ep->creation = 0;
ep->id = 0;
@@ -142,16 +161,22 @@ queue_envelope_create(struct envelope *ep)
int
queue_envelope_delete(struct envelope *ep)
{
- return env->sc_queue->envelope(QOP_DELETE, ep);
+ return env->sc_queue->envelope(QOP_DELETE, &ep->id, NULL, 0);
}
int
queue_envelope_load(uint64_t evpid, struct envelope *ep)
{
const char *e;
+ char evpbuf[sizeof(struct envelope)];
+ size_t evplen;
ep->id = evpid;
- if (env->sc_queue->envelope(QOP_LOAD, ep)) {
+ evplen = env->sc_queue->envelope(QOP_LOAD, &ep->id, evpbuf, sizeof evpbuf);
+ if (evplen == 0)
+ return (0);
+
+ if (queue_envelope_load_buffer(ep, evpbuf, evplen)) {
if ((e = envelope_validate(ep, evpid)) == NULL) {
ep->id = evpid;
return (1);
@@ -164,7 +189,14 @@ queue_envelope_load(uint64_t evpid, struct envelope *ep)
int
queue_envelope_update(struct envelope *ep)
{
- return env->sc_queue->envelope(QOP_UPDATE, ep);
+ char evpbuf[sizeof(struct envelope)];
+ size_t evplen;
+
+ evplen = queue_envelope_dump_buffer(ep, evpbuf, sizeof evpbuf);
+ if (evplen == 0)
+ return (0);
+
+ return env->sc_queue->envelope(QOP_UPDATE, &ep->id, evpbuf, evplen);
}
void *