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#13807: updated version to avoid MS-Windows vs non-MS-Windows clashes Date: Wed, 27 Feb 2013 20:49:42 +0200 Message-ID: <83txoxwq0p.fsf@gnu.org> References: <512A98D5.7080000@cs.ucla.edu> <512D3508.1000906@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1361991046 20367 80.91.229.3 (27 Feb 2013 18:50:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Feb 2013 18:50:46 +0000 (UTC) Cc: 13807@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Feb 27 19:51:09 2013 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 1UAm5t-0004Vk-Cx for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 19:51:09 +0100 Original-Received: from localhost ([::1]:47602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAm5V-0003ou-AQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Feb 2013 13:50:45 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:46000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAm5G-0003ZF-Rr for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 13:50:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAm50-0002lm-FZ for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 13:50:25 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAm50-0002kj-9q for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 13:50:14 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UAm6k-0003oU-36 for bug-gnu-emacs@gnu.org; Wed, 27 Feb 2013 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Feb 2013 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13807 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 13807-submit@debbugs.gnu.org id=B13807.136199109914622 (code B ref 13807); Wed, 27 Feb 2013 18:52:01 +0000 Original-Received: (at 13807) by debbugs.gnu.org; 27 Feb 2013 18:51:39 +0000 Original-Received: from localhost ([127.0.0.1]:53930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAm6N-0003nn-BX for submit@debbugs.gnu.org; Wed, 27 Feb 2013 13:51:39 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:37397) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UAm6L-0003nf-CG for 13807@debbugs.gnu.org; Wed, 27 Feb 2013 13:51:38 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MIW00M006HCWH00@a-mtaout20.012.net.il> for 13807@debbugs.gnu.org; Wed, 27 Feb 2013 20:49:43 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MIW00M4L6YUTS60@a-mtaout20.012.net.il>; Wed, 27 Feb 2013 20:49:43 +0200 (IST) In-reply-to: <512D3508.1000906@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:71923 Archived-At: > Date: Tue, 26 Feb 2013 14:19:52 -0800 > From: Paul Eggert > > Attached is an updated version of the patch, which avoids > several of the problems mentioned, by using a different lock file name > on MS-Windows. Non-MS-Windows uses .#FILE symlinks as before; > MS-Windows uses .#-FILE regular files. This avoids clashes > between the two approaches. It also means MS-Windows ignores > non-MS-Windows locks and vice versa, but given all the > inherent incompatibilities involved this may be the best that > we can do reliably. I think I found a better solution (committed as trunk revision 111888). Instead of using 'emacs_open', which just calls 'open', I now use '_sopen', which allows to specify sharing restrictions for accessing the same file via other file descriptors, both by the same Emacs which is creating the lock file, and by other processes. The sharing flag I used denies any kind of access to the same file until the file descriptor returned by _sopen is closed. This makes the whole open/write/close sequence in create_lock_file atomic, as far as other potential readers or writers of the file are concerned -- they will not be able to access the file until its contents is ready. I tested this with one NFS-mounted volume that can be accessed from both Windows and a GNU/Linux box. The results were that when Emacs running on GNU/Linux had the file locked, Emacs running on Windows would refrain from locking it, and vice versa when the file was locked by Emacs running on Windows and a GNU/Linux Emacs would try to lock it. This is IMO better than ignoring the locks from the other platform, because the latter means each Emacs thinks it has an exclusive lock on the file, while in fact there are several lockers. I can make a similar change in read_lock_data, but I don't think it's needed there, since 'symlink' on Posix hosts is atomic, and thus Emacs on Windows will always either see the symlink in its final state or not at all. So I think with this change, there's no longer a need to use different file names for the lock files on Windows and on Posix hosts.