cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] Changes to ccvs/src/rcs.c [cvs1-11-x-branch]


From: Derek Robert Price
Subject: [Cvs-cvs] Changes to ccvs/src/rcs.c [cvs1-11-x-branch]
Date: Sun, 25 Sep 2005 22:14:54 -0400

Index: ccvs/src/rcs.c
diff -u ccvs/src/rcs.c:1.262.4.43 ccvs/src/rcs.c:1.262.4.44
--- ccvs/src/rcs.c:1.262.4.43   Thu Sep 22 18:13:26 2005
+++ ccvs/src/rcs.c      Mon Sep 26 02:14:48 2005
@@ -8619,6 +8619,26 @@
           real solution is to check each call to fprintf rather than waiting
           until the end like this.  */
        error (1, errno, "error writing to lock file %s", rcs_lockfile);
+
+    /* Flush and sync the file, or the user may be told the commit completed,
+     * while a server crash/power failure could still cause the data to be
+     * lost.
+     *
+     * Invoking rename(",<file>," , "<file>,v") on Linux and almost all UNIXs
+     * only flushes the inode for the target file to disk, it does not
+     * guarantee flush of the kernel buffers allocated for the ,<file>,.
+     * Depending upon the load on the machine, the Linux kernel's flush daemon
+     * process may not flush for a while.  In the meantime the CVS transaction
+     * could have been declared committed to the end CVS user (CVS process has
+     * returned the final "OK").  If the machine crashes prior to syncing the
+     * changes to disk, the committed transaction can be lost.
+     */
+    if (fflush (fp) != 0)
+       error (1, errno, "error flushing file `%s' to kernel buffers",
+              rcs_lockfile);
+    if (fsync (rcs_lockfd) < 0)
+       error (1, errno, "error fsyncing file `%s'", rcs_lockfile);
+
     if (fclose (fp) == EOF)
        error (1, errno, "error closing lock file %s", rcs_lockfile);
     rcs_lockfd = -1;




reply via email to

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