all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: 13807@debbugs.gnu.org
Subject: bug#13807: updated version to avoid MS-Windows vs non-MS-Windows	clashes
Date: Wed, 27 Feb 2013 20:49:42 +0200	[thread overview]
Message-ID: <83txoxwq0p.fsf@gnu.org> (raw)
In-Reply-To: <512D3508.1000906@cs.ucla.edu>

> Date: Tue, 26 Feb 2013 14:19:52 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> 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.





  reply	other threads:[~2013-02-27 18:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-24 22:48 bug#13807: The lock for 'DIR/FILE' should always be 'DIR/.#FILE' Paul Eggert
2013-02-25 19:57 ` Glenn Morris
2013-02-25 23:40   ` Paul Eggert
2013-02-26 22:19 ` bug#13807: updated version to avoid MS-Windows vs non-MS-Windows clashes Paul Eggert
2013-02-27 18:49   ` Eli Zaretskii [this message]
2013-03-02 20:43     ` Paul Eggert
2013-03-02 21:17       ` Eli Zaretskii
2013-03-02 22:37         ` Paul Eggert
2013-03-03 16:39           ` Eli Zaretskii
2013-03-03 23:56             ` Paul Eggert
2013-03-04 16:50               ` Eli Zaretskii
2013-03-05  2:25                 ` Paul Eggert
2013-03-05 18:38                   ` Eli Zaretskii
2013-03-05 22:38                     ` Paul Eggert

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83txoxwq0p.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=13807@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.