From e3807a3f8feccc9ddb8d8f239fdde6c9209063de Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Tue, 31 Oct 1995 08:22:13 +0000 Subject: [PATCH] Put fsync under #ifdef EXTRA_SANITY and turn it off by default. fsync here cause real disk trashing when large UUCP mail chanks parsed. --- libexec/mail.local/Makefile | 1 + libexec/mail.local/mail.local.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libexec/mail.local/Makefile b/libexec/mail.local/Makefile index 2f22012480f4..ea539a67d348 100644 --- a/libexec/mail.local/Makefile +++ b/libexec/mail.local/Makefile @@ -2,6 +2,7 @@ PROG= mail.local MAN8= mail.local.8 +# CFLAGS+= -DEXTRA_SAFETY BINOWN= root BINMODE=4555 INSTALLFLAGS=-fschg diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c index 6effa031b227..d7b43a607f34 100644 --- a/libexec/mail.local/mail.local.c +++ b/libexec/mail.local/mail.local.c @@ -288,23 +288,25 @@ deliver(fd, name) if ((nw = write(mbfd, buf + off, nr)) < 0) { e_to_sys(errno); warn("%s: %s", path, strerror(errno)); - goto err2;; + goto err2; } if (nr < 0) { e_to_sys(errno); warn("temporary file: %s", strerror(errno)); - goto err2;; - } - - /* Flush to disk, don't wait for update. */ - if (fsync(mbfd)) { - e_to_sys(errno); - warn("%s: %s", path, strerror(errno)); err2: (void)ftruncate(mbfd, curoff); err1: (void)close(mbfd); return; } +#ifdef EXTRA_SAFETY + /* Flush to disk, don't wait for update. */ + if (fsync(mbfd)) { + e_to_sys(errno); + warn("%s: %s", path, strerror(errno)); + goto err2; + } +#endif + /* Close and check -- NFS doesn't write until the close. */ if (close(mbfd)) { e_to_sys(errno);