From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#66993: [PATCH] project.el: avoid asking user about project-list-file lock Date: Wed, 08 Nov 2023 09:52:16 -0500 Message-ID: References: <87h6lwelg7.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2474"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66993@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 08 15:54:01 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r0jwP-0000LM-Ap for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Nov 2023 15:54:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0jvv-0001XI-D9; Wed, 08 Nov 2023 09:53:31 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0jvr-0001WP-G4 for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 09:53:29 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r0jvn-0002NA-Ut for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 09:53:27 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r0jwQ-0002mV-9S for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2023 09:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Nov 2023 14:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66993 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66993-submit@debbugs.gnu.org id=B66993.169945518310617 (code B ref 66993); Wed, 08 Nov 2023 14:54:02 +0000 Original-Received: (at 66993) by debbugs.gnu.org; 8 Nov 2023 14:53:03 +0000 Original-Received: from localhost ([127.0.0.1]:44266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0jvT-0002lA-B6 for submit@debbugs.gnu.org; Wed, 08 Nov 2023 09:53:03 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:60049) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r0jvR-0002kd-8o for 66993@debbugs.gnu.org; Wed, 08 Nov 2023 09:53:02 -0500 In-Reply-To: <87h6lwelg7.fsf@gmx.de> (Michael Albinus's message of "Wed, 08 Nov 2023 08:46:48 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:273990 Archived-At: Michael Albinus writes: > Spencer Baugh writes: > > Hi Spencer, > >> If a user has multiple Emacs instances open using one or more of these >> features, it's fairly easy for both of the Emacs instances to see a >> new project at the same time. In that case, they'll both call >> project--write-project-list at the same time, which will clash and run >> ask-user-about-lock. This will happen frequently if the user is often >> looking at new projects. >> >> There's no correct answer the user can give to ask-user-about-lock: >> either way, one of the Emacs instances will have its project-list-file >> update lost. So let's not even bother prompting the user: just do >> nothing if project-list-file is currently locked. > > If you don't care about locking project-list-file, let-bind > create-lockfiles to nil while writing project-list-file. Hm, I think that could result in two writes clobbering each other in a way that creates an invalidly formatted file. This would happen if e.g. there were two concurrent write-regions that got interleaved like: 1. write-region(A) starts and writes first half 2. write-region(B) starts and completes 3. write-region(A) writes second half Then it would be some combination of A and B, which might not be validly formatted. From a brief look at the write-region implementation, this is possible. (The thing that would make this impossible is if write-region wrote into a tempfile and then renamed it on top of the destination. Instead write-region just writes directly into the file, opening it with O_TRUNC.) It's not very likely, but if the lock is conflicting at all and the project list is large then this will probably happen eventually.