-
Paul Eggert authored
The old approach, which fell back on DIR/.#FILE.0 through DIR/.#FILE.9, had race conditions that could not be easily fixed. If DIR/.#FILE is a non-symlink file, Emacs now does not create a lock file for DIR/FILE; that is, DIR/FILE is no longer partly protected by a lock if DIR/.#FILE is a non-symlink file ("partly" because the locking mechanism was never reliable in that case). This patch fixes this and other bugs discovered by a code inspection that was prompted by <http://lists.gnu.org/archive/html/emacs-devel/2013-02/msg00531.html>. Also, this patch switches to .#-FILE (not .#FILE) on MS-Windows, to avoid interoperability problems between the MS-Windows and non-MS-Windows implementations. MS-Windows and non-MS-Windows instances of Emacs now ignore each others' locks. * etc/NEWS: Document this. * src/filelock.c (defined_WINDOWSNT): New constant. (MAKE_LOCK_NAME, fill_in_lock_file_name): Don't create DIR/.#FILE.0 through DIR/.#FILE.9. Instead, create DIR/.#FILE symlinks on non-MS-Windows hosts, and DIR/.#-FILE regular files on MS-Windows hosts. (MAKE_LOCK_NAME, unlock_file, Ffile_locked_p): Use SAFE_ALLOCA to avoid problems with long file names. (MAX_LFINFO): Now a local constant, not a global macro. (IS_LOCK_FILE): Remove. (lock_file_1): Don't inspect errno if symlink call succeeds; that's not portable. (lock_file): Document that this function can return if lock creation fails. Fixes: debbugs:13807
b5029e23