nmh-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nmh-commits] nmh/sbr lock_file.c


From: Peter Maydell
Subject: [Nmh-commits] nmh/sbr lock_file.c
Date: Sun, 29 Apr 2007 20:49:33 +0000

CVSROOT:        /cvsroot/nmh
Module name:    nmh
Changes by:     Peter Maydell <pm215>   07/04/29 20:49:33

Modified files:
        sbr            : lock_file.c 

Log message:
        Minor rearrangement so variables/functions used only if 
!HAVE_LIBLOCKFILE
        are also declared only in that case.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/nmh/sbr/lock_file.c?cvsroot=nmh&r1=1.13&r2=1.14

Patches:
Index: lock_file.c
===================================================================
RCS file: /cvsroot/nmh/nmh/sbr/lock_file.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- lock_file.c 16 Jan 2006 10:00:47 -0000      1.13
+++ lock_file.c 29 Apr 2007 20:49:32 -0000      1.14
@@ -2,7 +2,7 @@
 /*
  * lock.c -- routines to lock/unlock files
  *
- * $Id: lock_file.c,v 1.13 2006/01/16 10:00:47 opk Exp $
+ * $Id: lock_file.c,v 1.14 2007/04/29 20:49:32 pm215 Exp $
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -105,13 +105,15 @@
 
 #ifdef DOT_LOCKING
 static int lkopen_dot (char *, int, mode_t);
-static int lockit (struct lockinfo *);
 static void lockname (char *, struct lockinfo *, int);
 static void timerON (char *, int);
 static void timerOFF (int);
 static RETSIGTYPE alrmser (int);
 #endif
 
+#if !defined(HAVE_LIBLOCKFILE)
+static int lockit (struct lockinfo *);
+#endif
 
 /*
  * Base routine to open and lock a file,
@@ -356,10 +358,8 @@
 static int
 lkopen_dot (char *file, int access, mode_t mode)
 {
-    int i, fd;
-    time_t curtime;
+    int fd;
     struct lockinfo lkinfo;
-    struct stat st;
 
     /* open the file */
     if ((fd = open (file, access, mode)) == -1)
@@ -372,6 +372,8 @@
     lockname (file, &lkinfo, 1);
 
 #if !defined(HAVE_LIBLOCKFILE)
+    {
+       int i;
     for (i = 0;;) {
        /* attempt to create lock file */
        if (lockit (&lkinfo) == 0) {
@@ -383,11 +385,13 @@
             * Abort locking, if we fail to lock after 5 attempts
             * and are never able to stat the lock file.
             */
+               struct stat st;
            if (stat (lkinfo.curlock, &st) == -1) {
                if (i++ > 5)
                    return -1;
                sleep (5);
            } else {
+                   time_t curtime;
                i = 0;
                time (&curtime);
 
@@ -400,6 +404,7 @@
            lockname (file, &lkinfo, 1);
        }
     }
+    }
 #else
     if (lockfile_create(lkinfo.curlock, 5, 0) == L_SUCCESS) {
         timerON(lkinfo.curlock, fd);
@@ -598,7 +603,6 @@
 static RETSIGTYPE
 alrmser (int sig)
 {
-    int j;
     char *lockfile;
     struct lock *lp;
 
@@ -610,8 +614,11 @@
     for (lp = l_top; lp; lp = lp->l_next) {
        lockfile = lp->l_lock;
 #if !defined(HAVE_LIBLOCKFILE)
+       {
+           int j;
        if (*lockfile && (j = creat (lockfile, 0600)) != -1)
            close (j);
+       }
 #else
     lockfile_touch(lockfile);
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]