From 855166cab18c755f280c77646aea8d1295931627 Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Thu, 9 Jul 2009 14:37:16 +0200 Subject: [PATCH] dma: lock temp files on creation Lock the temporary files after creating them to protect from a "dma -q" run at just the wrong time causing a double delivery attempt for the same message. Submitted-by: Peter Pentchev --- libexec/dma/dma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libexec/dma/dma.c b/libexec/dma/dma.c index 3ca98264a2..659963563e 100644 --- a/libexec/dma/dma.c +++ b/libexec/dma/dma.c @@ -223,6 +223,8 @@ gentempf(struct queue *queue) fd = mkstemp(fn); if (fd < 0) return (-1); + if (flock(fd, LOCK_EX) == -1) + return (-1); queue->mailfd = fd; queue->tmpf = strdup(fn); if (queue->tmpf == NULL) { -- 2.41.0