]> git.ipfire.org Git - people/ms/dma.git/commitdiff
don't complain when we can't lock a queue file during flush
authorSimon Schubert <2@0x2c.org>
Sat, 18 Feb 2012 00:02:18 +0000 (01:02 +0100)
committerSimon Schubert <2@0x2c.org>
Sat, 18 Feb 2012 00:02:18 +0000 (01:02 +0100)
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.

dma.c
spool.c

diff --git a/dma.c b/dma.c
index 02fb84618009a58b096d1b6a3e84454383d5c48f..c9508f227ab621f39fde89f36e86e8c800831cbe 100644 (file)
--- 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 25c6a99d2cee98929a2f50f81803cc24a703900e..7c7c08d5c53503ac56c8e43aa4f1741b0f9854b6 100644 (file)
--- 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);
 }