bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#13944: file synchronization fixes


From: Paul Eggert
Subject: bug#13944: file synchronization fixes
Date: Wed, 13 Mar 2013 00:38:00 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130308 Thunderbird/17.0.4

Tags: patch

The new code for creating regular-file lock files has a problem if
the system crashes while the lock file is being created: due to
races inside the file system, if the crash occurs at the wrong time
the file system may end up with an empty regular-file lock file,
which after the reboot will cause Emacs to bypass locking for that
file indefinitely (unless the empty lock file is removed manually
by the user).

On a POSIX-conforming system the problem can occur only if the
system crashes just as a lock file is being created.  Fixing this
requires using a synchronization primitive such as fsync on the
newly created file, before renaming it.

While looking into this I noticed some other file synchronization
problems.  fsync is used sometimes when fdatasync will do.  Emacs
does not consistently retry fsync after being interrupted.  It
sometimes incorrectly reports an error merely because fsync isn't
supported.  And it sometimes incorrectly skips fsync merely because
we are on a non-BSD system.

Attached a patch which I'd like to install.  If MS-Windows has fdatasync
already this should build on MS-Windows; if not, the MS-Windows port
needs to compile lib/fdatasync.c or support an fdatasync substitute
in some other way.

Attachment: fsync.txt
Description: Text document


reply via email to

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