From: Eli Zaretskii <eliz@gnu.org>
To: Glenn Morris <rgm@gnu.org>
Cc: 18828@debbugs.gnu.org
Subject: bug#18828: 24.4; Early collision warning when 'create-lockfiles' is set to nil
Date: Wed, 29 Apr 2015 19:16:19 +0300 [thread overview]
Message-ID: <83lhhaucz0.fsf@gnu.org> (raw)
In-Reply-To: <bzsibjdj11.fsf@fencepost.gnu.org>
> From: Glenn Morris <rgm@gnu.org>
> Date: Wed, 29 Apr 2015 11:57:30 -0400
> Cc: 18828@debbugs.gnu.org
>
> Dani Moncayo wrote:
>
> >> Don't set create-lockfiles to nil?
> >> That's the traditional mechanism by which Emacs manages this stuff.
> >
> > Well, that's not what some users (like myself) may want.
>
> Can only fall back to "patches welcome" then. :(
Here you go (if no one objects, I will push this in a few days):
--- src/filelock.c~0 2015-01-26 14:45:50 +0200
+++ src/filelock.c 2015-04-29 13:46:42 +0300
@@ -669,10 +669,6 @@ lock_file (Lisp_Object fn)
struct gcpro gcpro1;
USE_SAFE_ALLOCA;
- /* Don't do locking if the user has opted out. */
- if (! create_lockfiles)
- return;
-
/* Don't do locking while dumping Emacs.
Uncompressing wtmp files uses call-process, which does not work
in an uninitialized Emacs. */
@@ -690,9 +686,6 @@ lock_file (Lisp_Object fn)
#endif
encoded_fn = ENCODE_FILE (fn);
- /* Create the name of the lock-file for file fn */
- MAKE_LOCK_NAME (lfname, encoded_fn);
-
/* See if this file is visited and has changed on disk since it was
visited. */
{
@@ -707,27 +700,35 @@ lock_file (Lisp_Object fn)
}
- /* Try to lock the lock. */
- if (0 < lock_if_free (&lock_info, lfname))
+ /* Don't do locking if the user has opted out. */
+ if (create_lockfiles)
{
- /* Someone else has the lock. Consider breaking it. */
- Lisp_Object attack;
- char *dot = lock_info.dot;
- ptrdiff_t pidlen = lock_info.colon - (dot + 1);
- static char const replacement[] = " (pid ";
- int replacementlen = sizeof replacement - 1;
- memmove (dot + replacementlen, dot + 1, pidlen);
- strcpy (dot + replacementlen + pidlen, ")");
- memcpy (dot, replacement, replacementlen);
- attack = call2 (intern ("ask-user-about-lock"), fn,
- build_string (lock_info.user));
- /* Take the lock if the user said so. */
- if (!NILP (attack))
- lock_file_1 (lfname, 1);
+
+ /* Create the name of the lock-file for file fn */
+ MAKE_LOCK_NAME (lfname, encoded_fn);
+
+ /* Try to lock the lock. */
+ if (0 < lock_if_free (&lock_info, lfname))
+ {
+ /* Someone else has the lock. Consider breaking it. */
+ Lisp_Object attack;
+ char *dot = lock_info.dot;
+ ptrdiff_t pidlen = lock_info.colon - (dot + 1);
+ static char const replacement[] = " (pid ";
+ int replacementlen = sizeof replacement - 1;
+ memmove (dot + replacementlen, dot + 1, pidlen);
+ strcpy (dot + replacementlen + pidlen, ")");
+ memcpy (dot, replacement, replacementlen);
+ attack = call2 (intern ("ask-user-about-lock"), fn,
+ build_string (lock_info.user));
+ /* Take the lock if the user said so. */
+ if (!NILP (attack))
+ lock_file_1 (lfname, 1);
+ }
+ SAFE_FREE ();
}
UNGCPRO;
- SAFE_FREE ();
}
void
next prev parent reply other threads:[~2015-04-29 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 15:07 bug#18828: 24.4; Early collision warning when 'create-lockfiles' is set to nil Dani Moncayo
2015-03-14 4:12 ` Daniel Lopez
2015-04-29 9:59 ` Dani Moncayo
2015-04-29 15:44 ` Glenn Morris
2015-04-29 15:53 ` Dani Moncayo
2015-04-29 15:57 ` Glenn Morris
2015-04-29 16:16 ` Eli Zaretskii [this message]
2015-05-04 21:12 ` Dani Moncayo
2015-05-08 9:22 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83lhhaucz0.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=18828@debbugs.gnu.org \
--cc=rgm@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).