lock stats file before posting
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 29 Aug 1993 00:34:45 +0000 (16:34 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 29 Aug 1993 00:34:45 +0000 (16:34 -0800)
SCCS-vsn: usr.sbin/sendmail/src/stats.c 8.3

usr/src/usr.sbin/sendmail/src/stats.c

index 995f400..1d9136c 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)stats.c    8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)stats.c    8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -69,12 +69,13 @@ poststats(sfile)
        (void) time(&Stat.stat_itime);
        Stat.stat_size = sizeof Stat;
 
        (void) time(&Stat.stat_itime);
        Stat.stat_size = sizeof Stat;
 
-       fd = open(sfile, 2);
+       fd = open(sfile, O_RDWR);
        if (fd < 0)
        {
                errno = 0;
                return;
        }
        if (fd < 0)
        {
                errno = 0;
                return;
        }
+       (void) lockfile(fd, sfile, NULL, LOCK_EX);
        if (read(fd, (char *) &stat, sizeof stat) == sizeof stat &&
            stat.stat_size == sizeof stat)
        {
        if (read(fd, (char *) &stat, sizeof stat) == sizeof stat &&
            stat.stat_size == sizeof stat)
        {