all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: Tramp and timers
Date: Sun, 13 Dec 2020 12:43:17 -0500	[thread overview]
Message-ID: <jwvy2i1ligv.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87ft4c5lfu.fsf@gmx.de> (Michael Albinus's message of "Fri, 11 Dec 2020 17:58:29 +0100")

> Tramp is plagued since ever with timers, which run while Tramp is
> performing accept-process-output. If such a timer runs an operation
> which includes also a remote file operation, it ruins Tramp's current
> process handling. See the discussion at
> <https://lists.gnu.org/archive/html/tramp-devel/2020-12/msg00003.html>
> for a recent problem.

Here's my take on it (I'm not familiar enough with the code to be sure
it's workable, so it's more like a backseat driver's design, so feel
free to ignore):

I think it should be OK for the timer to access a Tramp file on host
A while we're in the middle of a Tramp access to a file on host B.
So the interference should be detected "per connection" rather than
globally.

Every connection should have a lock.  Whenever the connection is "in
use", we take the lock.  This is also useful in the case of the use
of threads.  When we try to take the lock and it's already taken by
another thread, we should just wait (or rather, the lock should do that
for us), but if it's already taken by the current thread then we should
instead signal an error like `tramp-recursive-access`.

Timers should arguably each run in their own thread.  Of course, they
(currently) don't, but if a timer function wants to use Tramp files,
then it should start by delegating its job to a thread (we should
probably have a standard function like `run-with-timer-concurrent` which
calls the timer function in a separate thread).  If they don't, then the
risk getting `tramp-recursive-access`.

IIUC your proposal is quite similar to what I describe,


        Stefan




  reply	other threads:[~2020-12-13 17:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 16:58 Tramp and timers Michael Albinus
2020-12-13 17:43 ` Stefan Monnier [this message]
2020-12-13 18:37   ` Michael Albinus
2020-12-13 20:55     ` Stefan Monnier
2020-12-14  7:55       ` Michael Albinus

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=jwvy2i1ligv.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /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.