add "ext" argument to lockfile so you can accurately tell what file
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 23 Aug 1993 23:32:40 +0000 (15:32 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Mon, 23 Aug 1993 23:32:40 +0000 (15:32 -0800)
is being locked in logging/error messages

SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 8.17
SCCS-vsn: usr.sbin/sendmail/src/util.c 8.8
SCCS-vsn: usr.sbin/sendmail/src/queue.c 8.15
SCCS-vsn: usr.sbin/sendmail/src/conf.c 8.26
SCCS-vsn: usr.sbin/sendmail/src/alias.c 8.12
SCCS-vsn: usr.sbin/sendmail/src/map.c 8.9

usr/src/usr.sbin/sendmail/src/alias.c
usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/map.c
usr/src/usr.sbin/sendmail/src/queue.c
usr/src/usr.sbin/sendmail/src/sendmail.h
usr/src/usr.sbin/sendmail/src/util.c

index 611d2c7..3e7db12 100644 (file)
@@ -10,7 +10,7 @@
 # include <pwd.h>
 
 #ifndef lint
 # include <pwd.h>
 
 #ifndef lint
-static char sccsid[] = "@(#)alias.c    8.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)alias.c    8.12 (Berkeley) %G%";
 #endif /* not lint */
 
 
 #endif /* not lint */
 
 
@@ -371,7 +371,7 @@ rebuildaliases(map, automatic)
        }
 
        /* see if someone else is rebuilding the alias file */
        }
 
        /* see if someone else is rebuilding the alias file */
-       if (!lockfile(fileno(af), map->map_file, LOCK_EX|LOCK_NB))
+       if (!lockfile(fileno(af), map->map_file, NULL, LOCK_EX|LOCK_NB))
        {
                /* yes, they are -- wait until done */
                message("Alias file %s is already being rebuilt",
        {
                /* yes, they are -- wait until done */
                message("Alias file %s is already being rebuilt",
@@ -379,7 +379,7 @@ rebuildaliases(map, automatic)
                if (OpMode != MD_INITALIAS)
                {
                        /* wait for other rebuild to complete */
                if (OpMode != MD_INITALIAS)
                {
                        /* wait for other rebuild to complete */
-                       (void) lockfile(fileno(af), map->map_file,
+                       (void) lockfile(fileno(af), map->map_file, NULL,
                                        LOCK_EX);
                }
                (void) fclose(af);
                                        LOCK_EX);
                }
                (void) fclose(af);
index 30555de..a39709a 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     8.25 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.26 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -1494,6 +1494,7 @@ transienterror(err)
 **     Parameters:
 **             fd -- the file descriptor of the file.
 **             filename -- the file name (for error messages).
 **     Parameters:
 **             fd -- the file descriptor of the file.
 **             filename -- the file name (for error messages).
+**             ext -- the filename extension.
 **             type -- type of the lock.  Bits can be:
 **                     LOCK_EX -- exclusive lock.
 **                     LOCK_NB -- non-blocking.
 **             type -- type of the lock.  Bits can be:
 **                     LOCK_EX -- exclusive lock.
 **                     LOCK_NB -- non-blocking.
@@ -1504,14 +1505,18 @@ transienterror(err)
 */
 
 bool
 */
 
 bool
-lockfile(fd, filename, type)
+lockfile(fd, filename, ext, type)
        int fd;
        char *filename;
        int fd;
        char *filename;
+       char *ext;
        int type;
 {
 # ifndef HASFLOCK
        int action;
        struct flock lfd;
        int type;
 {
 # ifndef HASFLOCK
        int action;
        struct flock lfd;
+
+       if (ext == NULL)
+               ext = "";
                
        bzero(&lfd, sizeof lfd);
        if (bitset(LOCK_UN, type))
                
        bzero(&lfd, sizeof lfd);
        if (bitset(LOCK_UN, type))
@@ -1527,8 +1532,8 @@ lockfile(fd, filename, type)
                action = F_SETLKW;
 
        if (tTd(55, 60))
                action = F_SETLKW;
 
        if (tTd(55, 60))
-               printf("lockfile(%s, action=%d, type=%d): ",
-                       filename, action, lfd.l_type);
+               printf("lockfile(%s%s, action=%d, type=%d): ",
+                       filename, ext, action, lfd.l_type);
 
        if (fcntl(fd, action, &lfd) >= 0)
        {
 
        if (fcntl(fd, action, &lfd) >= 0)
        {
@@ -1557,10 +1562,13 @@ lockfile(fd, filename, type)
        }
 
        if (!bitset(LOCK_NB, type) || (errno != EACCES && errno != EAGAIN))
        }
 
        if (!bitset(LOCK_NB, type) || (errno != EACCES && errno != EAGAIN))
-               syserr("cannot lockf(%s, %o)", filename, type);
+               syserr("cannot lockf(%s%s, %o)", filename, ext, type);
 # else
 # else
+       if (ext == NULL)
+               ext = "";
+
        if (tTd(55, 60))
        if (tTd(55, 60))
-               printf("lockfile(%s, type=%o): ", filename, type);
+               printf("lockfile(%s%s, type=%o): ", filename, ext, type);
 
        if (flock(fd, type) >= 0)
        {
 
        if (flock(fd, type) >= 0)
        {
@@ -1573,7 +1581,7 @@ lockfile(fd, filename, type)
                printf("(%s) ", errstring(errno));
 
        if (!bitset(LOCK_NB, type) || errno != EWOULDBLOCK)
                printf("(%s) ", errstring(errno));
 
        if (!bitset(LOCK_NB, type) || errno != EWOULDBLOCK)
-               syserr("cannot flock(%s, %o)", filename, type);
+               syserr("cannot flock(%s%s, %o)", filename, ext, type);
 # endif
        if (tTd(55, 60))
                printf("FAIL\n");
 # endif
        if (tTd(55, 60))
                printf("FAIL\n");
index ef4cf36..4061aa9 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)map.c      8.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)map.c      8.9 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "sendmail.h"
 #endif /* not lint */
 
 #include "sendmail.h"
@@ -425,7 +425,8 @@ ndbm_map_lookup(map, name, av, statp)
                makelower(keybuf);
                key.dptr = keybuf;
        }
                makelower(keybuf);
                key.dptr = keybuf;
        }
-       (void) lockfile(dbm_dirfno((DBM *) map->map_db1), map->map_file, LOCK_SH);
+       (void) lockfile(dbm_dirfno((DBM *) map->map_db1), map->map_file,
+                       ".dir", LOCK_SH);
        val.dptr = NULL;
        if (bitset(MF_TRY0NULL, map->map_mflags))
        {
        val.dptr = NULL;
        if (bitset(MF_TRY0NULL, map->map_mflags))
        {
@@ -440,7 +441,8 @@ ndbm_map_lookup(map, name, av, statp)
                if (val.dptr != NULL)
                        map->map_mflags &= ~MF_TRY0NULL;
        }
                if (val.dptr != NULL)
                        map->map_mflags &= ~MF_TRY0NULL;
        }
-       (void) lockfile(dbm_dirfno((DBM *) map->map_db1), map->map_file, LOCK_UN);
+       (void) lockfile(dbm_dirfno((DBM *) map->map_db1), map->map_file,
+                       ".dir", LOCK_UN);
        if (val.dptr == NULL)
                return NULL;
        if (bitset(MF_MATCHONLY, map->map_mflags))
        if (val.dptr == NULL)
                return NULL;
        if (bitset(MF_MATCHONLY, map->map_mflags))
@@ -585,10 +587,10 @@ bt_map_open(map, mode)
 #if !defined(OLD_NEWDB) && defined(HASFLOCK)
 # if !defined(O_EXLOCK)
        if (mode == O_RDWR)
 #if !defined(OLD_NEWDB) && defined(HASFLOCK)
 # if !defined(O_EXLOCK)
        if (mode == O_RDWR)
-               (void) lockfile(db->fd(db), map->map_file, LOCK_EX);
+               (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_EX);
 # else
        if (mode == O_RDONLY)
 # else
        if (mode == O_RDONLY)
-               (void) lockfile(db->fd(db), map->map_file, LOCK_UN);
+               (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_UN);
 # endif
 #endif
 
 # endif
 #endif
 
@@ -655,10 +657,10 @@ hash_map_open(map, mode)
 #if !defined(OLD_NEWDB) && defined(HASFLOCK)
 # if !defined(O_EXLOCK)
        if (mode == O_RDWR)
 #if !defined(OLD_NEWDB) && defined(HASFLOCK)
 # if !defined(O_EXLOCK)
        if (mode == O_RDWR)
-               (void) lockfile(db->fd(db), map->map_file, LOCK_EX);
+               (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_EX);
 # else
        if (mode == O_RDONLY)
 # else
        if (mode == O_RDONLY)
-               (void) lockfile(db->fd(db), map->map_file, LOCK_UN);
+               (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_UN);
 # endif
 #endif
 
 # endif
 #endif
 
@@ -706,7 +708,7 @@ db_map_lookup(map, name, av, statp)
        if (!bitset(MF_NOFOLDCASE, map->map_mflags))
                makelower(keybuf);
 #ifndef OLD_NEWDB
        if (!bitset(MF_NOFOLDCASE, map->map_mflags))
                makelower(keybuf);
 #ifndef OLD_NEWDB
-       (void) lockfile(db->fd(db), map->map_file, LOCK_SH);
+       (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_SH);
 #endif
        st = 1;
        if (bitset(MF_TRY0NULL, map->map_mflags))
 #endif
        st = 1;
        if (bitset(MF_TRY0NULL, map->map_mflags))
@@ -724,7 +726,7 @@ db_map_lookup(map, name, av, statp)
        }
        saveerrno = errno;
 #ifndef OLD_NEWDB
        }
        saveerrno = errno;
 #ifndef OLD_NEWDB
-       (void) lockfile(db->fd(db), map->map_file, LOCK_UN);
+       (void) lockfile(db->fd(db), map->map_file, ".db", LOCK_UN);
 #endif
        if (st != 0)
        {
 #endif
        if (st != 0)
        {
index f1d5094..c28f9c3 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef QUEUE
 
 #ifndef lint
 #ifdef QUEUE
-static char sccsid[] = "@(#)queue.c    8.14 (Berkeley) %G% (with queueing)";
+static char sccsid[] = "@(#)queue.c    8.15 (Berkeley) %G% (with queueing)";
 #else
 #else
-static char sccsid[] = "@(#)queue.c    8.14 (Berkeley) %G% (without queueing)";
+static char sccsid[] = "@(#)queue.c    8.15 (Berkeley) %G% (without queueing)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -105,7 +105,7 @@ queueup(e, queueall, announce)
                                continue;
                        }
 
                                continue;
                        }
 
-                       if (lockfile(fd, tf, LOCK_EX|LOCK_NB))
+                       if (lockfile(fd, tf, NULL, LOCK_EX|LOCK_NB))
                                break;
 #ifdef LOG
                        else if (LogLevel > 0 && (i % 32) == 0)
                                break;
 #ifdef LOG
                        else if (LogLevel > 0 && (i % 32) == 0)
@@ -932,7 +932,7 @@ readqf(e, announcefile)
                return FALSE;
        }
 
                return FALSE;
        }
 
-       if (!lockfile(fileno(qfp), qf, LOCK_EX|LOCK_NB))
+       if (!lockfile(fileno(qfp), qf, NULL, LOCK_EX|LOCK_NB))
        {
                /* being processed by another queuer */
                if (tTd(40, 8))
        {
                /* being processed by another queuer */
                if (tTd(40, 8))
@@ -1213,7 +1213,7 @@ printqueue()
                        continue;
                }
                printf("%8s", w->w_name + 2);
                        continue;
                }
                printf("%8s", w->w_name + 2);
-               if (!lockfile(fileno(f), w->w_name, LOCK_SH|LOCK_NB))
+               if (!lockfile(fileno(f), w->w_name, NULL, LOCK_SH|LOCK_NB))
                        printf("*");
                else if (shouldqueue(w->w_pri, w->w_ctime))
                        printf("X");
                        printf("*");
                else if (shouldqueue(w->w_pri, w->w_ctime))
                        printf("X");
@@ -1379,7 +1379,7 @@ queuename(e, type)
                                        qf, QueueDir);
                                exit(EX_UNAVAILABLE);
                        }
                                        qf, QueueDir);
                                exit(EX_UNAVAILABLE);
                        }
-                       if (lockfile(i, qf, LOCK_EX|LOCK_NB))
+                       if (lockfile(i, qf, NULL, LOCK_EX|LOCK_NB))
                        {
                                e->e_lockfp = fdopen(i, "w");
                                break;
                        {
                                e->e_lockfp = fdopen(i, "w");
                                break;
index f193e9a..e21b65b 100644 (file)
@@ -5,7 +5,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)sendmail.h  8.16 (Berkeley) %G%
+ *     @(#)sendmail.h  8.17 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -15,7 +15,7 @@
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
 # ifdef _DEFINE
 # define EXTERN
 # ifndef lint
-static char SmailSccsId[] =    "@(#)sendmail.h 8.16            %G%";
+static char SmailSccsId[] =    "@(#)sendmail.h 8.17            %G%";
 # endif
 # else /*  _DEFINE */
 # define EXTERN extern
 # endif
 # else /*  _DEFINE */
 # define EXTERN extern
@@ -904,7 +904,7 @@ extern ADDRESS              *getctladdr __P((ADDRESS *));
 extern char            *anynet_ntoa __P((SOCKADDR *));
 extern char            *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
 extern bool            shouldqueue __P((long, time_t));
 extern char            *anynet_ntoa __P((SOCKADDR *));
 extern char            *remotename __P((char *, MAILER *, int, int *, ENVELOPE *));
 extern bool            shouldqueue __P((long, time_t));
-extern bool            lockfile __P((int, char *, int));
+extern bool            lockfile __P((int, char *, char *, int));
 extern char            *hostsignature __P((MAILER *, char *, ENVELOPE *));
 extern void            openxscript __P((ENVELOPE *));
 extern void            closexscript __P((ENVELOPE *));
 extern char            *hostsignature __P((MAILER *, char *, ENVELOPE *));
 extern void            openxscript __P((ENVELOPE *));
 extern void            closexscript __P((ENVELOPE *));
index 497ea2d..1216349 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)util.c     8.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)util.c     8.8 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -603,7 +603,7 @@ dfopen(filename, omode, cmode)
                        locktype = LOCK_EX;
                else
                        locktype = LOCK_SH;
                        locktype = LOCK_EX;
                else
                        locktype = LOCK_SH;
-               (void) lockfile(fd, filename, locktype);
+               (void) lockfile(fd, filename, NULL, locktype);
                errno = 0;
        }
        if (fd < 0)
                errno = 0;
        }
        if (fd < 0)