From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18828: 24.4; Early collision warning when 'create-lockfiles' is set to nil Date: Wed, 29 Apr 2015 19:16:19 +0300 Message-ID: <83lhhaucz0.fsf@gnu.org> References: <5503B51D.3080100@gmail.com> <6ea8xrey7e.fsf@fencepost.gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1430324248 26731 80.91.229.3 (29 Apr 2015 16:17:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 29 Apr 2015 16:17:28 +0000 (UTC) Cc: 18828@debbugs.gnu.org To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 29 18:17:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YnUfg-00070Q-H4 for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Apr 2015 18:17:12 +0200 Original-Received: from localhost ([::1]:40011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnUff-0007o7-Ji for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Apr 2015 12:17:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnUfb-0007nl-R3 for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2015 12:17:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnUfX-0001v8-PB for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2015 12:17:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnUfX-0001uu-LQ for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2015 12:17:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1YnUfW-0001dX-Su for bug-gnu-emacs@gnu.org; Wed, 29 Apr 2015 12:17:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 Apr 2015 16:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18828 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18828-submit@debbugs.gnu.org id=B18828.14303242085900 (code B ref 18828); Wed, 29 Apr 2015 16:17:02 +0000 Original-Received: (at 18828) by debbugs.gnu.org; 29 Apr 2015 16:16:48 +0000 Original-Received: from localhost ([127.0.0.1]:56616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YnUfI-0001Wc-38 for submit@debbugs.gnu.org; Wed, 29 Apr 2015 12:16:48 -0400 Original-Received: from mtaout28.012.net.il ([80.179.55.184]:37541) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YnUfE-0001Qe-QS for 18828@debbugs.gnu.org; Wed, 29 Apr 2015 12:16:46 -0400 Original-Received: from conversion-daemon.mtaout28.012.net.il by mtaout28.012.net.il (HyperSendmail v2007.08) id <0NNK00H00SRO6R00@mtaout28.012.net.il> for 18828@debbugs.gnu.org; Wed, 29 Apr 2015 19:15:12 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout28.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NNK00H0OT5CWM10@mtaout28.012.net.il>; Wed, 29 Apr 2015 19:15:12 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:102241 Archived-At: > From: Glenn Morris > 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