]> diplodocus.org Git - nmh/blobdiff - uip/dropsbr.c
Make sure we are in the correct directory when we do "git describe".
[nmh] / uip / dropsbr.c
index 2274137..c492b18 100644 (file)
@@ -1,5 +1,4 @@
-/*
- * dropsbr.c -- create/read/manipulate mail drops
+/* dropsbr.c -- create/read/manipulate mail drops
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +12,8 @@
 #include <h/dropsbr.h>
 #include <h/mts.h>
 #include <h/tws.h>
+#include "../sbr/lock_file.h"
+#include "../sbr/m_mktemp.h"
 
 #ifdef NTOHLSWAP
 # include <netinet/in.h>
@@ -47,19 +48,16 @@ mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
     /* attempt to open and lock file */
     for (count = 4; count > 0; count--) {
         int failed_to_lock = 0;
-       if ((fd = lkopenspool (file, O_RDWR | O_CREAT |
-                              O_NONBLOCK, mode, &failed_to_lock)) == NOTOK) {
-            if (failed_to_lock) {
-                j = errno;
-                sleep (5);
-                continue;
-            } else {
-                return NOTOK;
-            }
-       }
 
-       /* good file descriptor */
-       break;
+       if ((fd = lkopenspool (file, O_RDWR | O_CREAT | O_NONBLOCK,
+            mode, &failed_to_lock)) != NOTOK)
+            break;
+
+        if (!failed_to_lock)
+            return NOTOK;
+
+        j = errno;
+        sleep (5);
     }
 
     errno = j;