all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Joost Kremers <joost.m.kremers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Best way to check file modification time?
Date: 19 Nov 2015 14:07:26 GMT	[thread overview]
Message-ID: <db63cuFfackU1@mid.individual.net> (raw)
In-Reply-To: mailman.78.1447780399.31583.help-gnu-emacs@gnu.org

Stefan Monnier wrote:
>>> I can easily move the mod time checking to a position in the code that's
>>> closer to the actual reading or saving of the file, but I suspect that
>>> only reduces the problem, it doesn't eliminate it altogether. So I'm
>>> wondering if there's a Right Way Ѣ to do this. If not, any advice on how
>>> to reduce the risks as much as possible would be great!
>
> You can't solve this without locking.

Which, if I understand the Elisp manual correctly, can only be done for
files being visited (which I don't do in order to avoid the overhead of
setting up the major mode and any minor modes the user may have
installed), and only works to lock out Emacs.

> The mod-time check has to be done before writing (since writing is
> conditional on the result of the mod-time check), you have a race:
>
>    User A checks mod-time
>    User B checks mod-time
>    User A writes
>    User B writes
>
> And this applies no matter how/when the mod-time was originally acquired.

Yes, I figured that. I was just wondering if there were a standard way
of dealing with such cases, since AFAIU it is possible to put a lock on
a file on the OS level. But Emacs doesn't do that, right?

Thanks for the answer, at least I know how to proceed now.



-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


  parent reply	other threads:[~2015-11-19 14:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17 11:09 Best way to check file modification time? Joost Kremers
2015-11-17 16:04 ` Barry Margolin
2015-11-17 17:12   ` Stefan Monnier
     [not found]   ` <mailman.78.1447780399.31583.help-gnu-emacs@gnu.org>
2015-11-19 14:07     ` Joost Kremers [this message]
2015-11-20 14:50       ` Stefan Monnier
2015-11-19 14:10   ` Joost Kremers

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=db63cuFfackU1@mid.individual.net \
    --to=joost.m.kremers@gmail.com \
    --cc=help-gnu-emacs@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 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.