[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8b36bfc553b 4/4: Remove empty (& invalid) lock files
From: |
Paul Eggert |
Subject: |
master 8b36bfc553b 4/4: Remove empty (& invalid) lock files |
Date: |
Thu, 15 Aug 2024 16:31:40 -0400 (EDT) |
branch: master
commit 8b36bfc553b97cf435bdfe1b84abe21c3a605b9f
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
Remove empty (& invalid) lock files
* src/filelock.c (current_lock_owner):
Remove empty lock files, as they are necessarily invalid
and can be caused by buggy file systems.
Problem reported by Michal Nazarewicz (bug#72641).
---
src/filelock.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/filelock.c b/src/filelock.c
index c68aacc46fb..1ae57dc7344 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -397,8 +397,8 @@ current_lock_owner (lock_info_type *owner, Lisp_Object
lfname)
if (lfinfolen < 0)
return errno == ENOENT || errno == ENOTDIR ? 0 : errno;
- /* Examine lock file contents. */
- if (true)
+ /* If the lock file seems valid, return a value based on its contents. */
+ if (lfinfolen)
{
if (MAX_LFINFO < lfinfolen)
return ENAMETOOLONG;
@@ -496,8 +496,11 @@ current_lock_owner (lock_info_type *owner, Lisp_Object
lfname)
return ANOTHER_OWNS_IT;
}
- /* The owner process is dead or has a strange pid.
- Try to zap the lockfile. */
+ /* The owner process is dead or has a strange pid, or the lock file is empty.
+ Try to zap the lockfile. If the lock file is empty, this assumes
+ the file system is buggy, e.g., <https://bugs.gnu.org/72641>.
+ Emacs never creates empty lock files even temporarily, so removing
+ an empty lock file should be harmless. */
return emacs_unlink (SSDATA (lfname)) < 0 ? errno : 0;
}