]> diplodocus.org Git - nmh/blobdiff - sbr/lock_file.c
seq_read.c: Move interface to own file.
[nmh] / sbr / lock_file.c
index 19cad331edb92dc501fb5fea2d416d1672581bf7..f8e4b6c7b08cdbf779865c7902e12c43f332e7d1 100644 (file)
  * Ruud de Rooij <ruud@debian.org>  Sun, 28 Mar 1999 15:34:03 +0200
  */
  
-#include <h/mh.h>
-#include <h/signals.h>
-#include <h/utils.h>
-#include <h/mts.h>
+#include "h/mh.h"
+#include "context_find.h"
+#include "error.h"
+#include "h/signals.h"
+#include "h/utils.h"
+#include "h/mts.h"
 #include "lock_file.h"
 #include "m_mktemp.h"
 
@@ -133,7 +135,8 @@ lkopendata(const char *file, int access, mode_t mode, int *failed_to_lock)
  * Locking using the spool locking algorithm
  */
 
-int lkopenspool(const char *file, int access, mode_t mode, int *failed_to_lock)
+int
+lkopenspool(const char *file, int access, mode_t mode, int *failed_to_lock)
 {
     static bool deja_vu;
 
@@ -314,7 +317,7 @@ lkopen (const char *file, int access, mode_t mode, enum locktype ltype,
 #endif /* HAVE_FLOCK */
 
     default:
-       adios(NULL, "Internal locking error: unsupported lock type used!");
+       die("Internal locking error: unsupported lock type used!");
     }
 
     return -1;
@@ -522,6 +525,7 @@ lkopen_dot (const char *file, int access, mode_t mode, int *failed_to_lock)
             lockname (file, &lkinfo, 1);
        }
 
+        close(fd);
         *failed_to_lock = 1;
         return -1;
     }
@@ -575,7 +579,7 @@ lockit (struct lockinfo *li)
     fd = link(tmpfile, curlock);
     (void) m_unlink(tmpfile);
 
-    return (fd == -1 ? -1 : 0);
+    return fd == -1 ? -1 : 0;
 }
 #endif /* HAVE_LIBLOCKFILE */
 
@@ -749,20 +753,20 @@ init_locktype(const char *lockname)
 #ifdef HAVE_LOCKF
        return LOCKF_LOCKING;
 #else /* ! HAVE_LOCKF */
-       adios(NULL, "lockf not supported on this system");
+       die("lockf not supported on this system");
 #endif /* HAVE_LOCKF */
     }
     if (strcasecmp(lockname, "flock") == 0) {
 #ifdef HAVE_FLOCK
        return FLOCK_LOCKING;
 #else /* ! HAVE_FLOCK */
-       adios(NULL, "flock not supported on this system");
+       die("flock not supported on this system");
 #endif /* HAVE_FLOCK */
     }
     if (strcasecmp(lockname, "dot") == 0) {
        return DOT_LOCKING;
     }
-    adios(NULL, "Unknown lock type: \"%s\"", lockname);
+    die("Unknown lock type: \"%s\"", lockname);
     /* NOTREACHED */
     return 0;
 }