From: Simon Schubert <2@0x2c.org> Date: Sat, 18 Feb 2012 00:02:18 +0000 (+0100) Subject: don't complain when we can't lock a queue file during flush X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e33faafea635e82a5c2018bc02718fdb68f09143;p=people%2Fms%2Fdma.git don't complain when we can't lock a queue file during flush When we can't lock a queue file during flush it means another process is already sitting on the item, so no need to complain or return error. --- diff --git a/dma.c b/dma.c index 02fb846..c9508f2 100644 --- a/dma.c +++ b/dma.c @@ -70,6 +70,7 @@ const char *logident_base; char errmsg[ERRMSG_SIZE]; static int daemonize = 1; +static int doqueue = 0; struct config config = { .smarthost = NULL, @@ -265,11 +266,21 @@ retit: /* * If necessary, acquire the queue and * mail files. * If this fails, we probably were raced by another - * process. + * process. It is okay to be raced if we're supposed + * to flush the queue. */ setlogident("%s", it->queueid); - if (acquirespool(it) < 0) + switch (acquirespool(it)) { + case 0: + break; + case 1: + if (doqueue) + exit(0); + syslog(LOG_WARNING, "could not lock queue file"); + exit(1); + default: exit(1); + } dropspool(queue, it); return (it); @@ -393,7 +404,7 @@ main(int argc, char **argv) char *sender = NULL; struct queue queue; int i, ch; - int nodot = 0, doqueue = 0, showq = 0, queue_only = 0; + int nodot = 0, showq = 0, queue_only = 0; int recp_from_header = 0; set_username(); diff --git a/spool.c b/spool.c index 25c6a99..7c7c08d 100644 --- a/spool.c +++ b/spool.c @@ -374,6 +374,8 @@ acquirespool(struct qitem *it) return (0); fail: + if (errno == EWOULDBLOCK) + return (1); syslog(LOG_INFO, "could not acquire queue file: %m"); return (-1); }