unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: rpluim@gmail.com, visuweshm@gmail.com, larsi@gnus.org,
	bugs@gnu.support, 50849@debbugs.gnu.org
Subject: bug#50849: 28.0.50; Proposal for Emacs daemon to signal when being busy
Date: Thu, 08 Sep 2022 08:59:40 +0300	[thread overview]
Message-ID: <83wnaefltf.fsf@gnu.org> (raw)
In-Reply-To: <CADwFkmm4pKkS5z_u6A7fUL_Y2TKK8pJBfqCqJhrcDzvd0CctVg@mail.gmail.com> (message from Stefan Kangas on Wed, 7 Sep 2022 18:47:03 -0700)

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Wed, 7 Sep 2022 18:47:03 -0700
> Cc: larsi@gnus.org, 50849@debbugs.gnu.org, bugs@gnu.support, 
> 	visuweshm@gmail.com
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > I actually don't understand why we need to call setsockopt
> 
> We need to call setsockopt to set the timeout.

When the timeout wasn't given by the user, I don't think it's our
business to second-guess what the user wants.

Setting a timeout in all cases is at least an incompatible behavior
change.  For example, imagine a use case where the delay is indeed
justified, and the user has no problems having emacsclient to wait for
more than 30 sec.  With the current code on master, we will output
messages that we previously didn't, and that could potentially break
someone's scripts.  Moreover, there's no way for users in such cases
to get back the old behavior, none whatsoever.  I don't see how can we
justify such an incompatible change.  The imaginary case I described
is probably rare at best, but it's still a legitimate one, and we had
better avoided breaking it, unless we have a very good reason.

> Based on section 13.2 in UNIX Network Programming, I guess we could call
> alarm(2) and set up a SIGALRM handler instead.

SIGALRM is non-portable, so it's a non-starter.

> > (without checking errors)
> 
> Adding error handling is easy enough, but what do you think we must do
> differently if the call to setsockopt fails?

Display an error message?

> IIUC, the recv call will just not timeout in that case, and things
> will be as if we hadn't tried to set any timeout at all.

Exactly.  But it means the user asked us to do something, and we
didn't.  The textbook behavior in such cases is to let the user know
that the contract was broken.

> > and then complicate our lives with no less
> > than 3 tricky-named flags ('retry' is not really what its name says,
> > msg_showed is initialized with a non-fixed value, etc.) when the
> > timeout was not given.
> 
> What would you name these flags instead?

Something that really tells us what they signify and how they are
used.  When there are 3 flags whose different combinations mean
different things, the code can be difficult to follow, understand, and
modify safely.

> And what does "etc." above mean?

That I could continue telling why the current flag-based
implementation is hard to read and understand.  At the very least, we
should have comments there explaining the logic.

> > Why not just avoid setting the timeout in that case?
> 
> Because we want to give the informational message "Server not
> responding; use Ctrl+C to break".  If we don't want that message, we
> don't need to set a timeout in that case.

See above: when the user doesn't use --timeout, he/she doesn't
necessarily want emacsclient to brag about the server not responding.

> > And in any case, saying that the default timeout is zero is simply
> > misleading.  We should either say that "by default emacscilent will
> > wait indefinitely" or modify DEFAULT_TIMEOUT to zero.
> 
> I think it makes sense to change the documentation as you suggest.

Then please do.  We currently don't describe the default behavior
correctly.  (Of course, if you eventually agree to change the code so
that no timeout is set on the socket, we just need to say that by
default there's no timeout.)

> (Note that DEFAULT_TIMEOUT really only has to do with the time to wait
> before printing an informational message, in the case when we did not
> get a --timeout flag.  Maybe it could get a better name.)

Either a better name (but what would be such a name?), or better
comments and documentation telling what it does.





  reply	other threads:[~2022-09-08  5:59 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 14:23 bug#50849: 28.0.50; Proposal for Emacs daemon to signal when being busy Jean Louis
2021-09-27 15:27 ` Eli Zaretskii
2021-09-28  5:56   ` Lars Ingebrigtsen
2021-09-28  7:08     ` Eli Zaretskii
2022-09-02 11:09       ` Lars Ingebrigtsen
2022-09-02 11:21         ` Eli Zaretskii
2022-09-02 12:28           ` Lars Ingebrigtsen
2022-09-02 12:39             ` Eli Zaretskii
2022-09-02 12:44               ` Robert Pluim
2022-09-02 13:02               ` Lars Ingebrigtsen
2022-09-02 13:54                 ` Visuwesh
2022-09-02 14:02                   ` Eli Zaretskii
2022-09-03  9:48                     ` Lars Ingebrigtsen
2022-09-03 15:40                       ` Stefan Kangas
2022-09-03 15:57                         ` Eli Zaretskii
2022-09-04 10:59                         ` Lars Ingebrigtsen
2022-09-05 13:56                       ` Stefan Kangas
2022-09-05 19:07                         ` Lars Ingebrigtsen
2022-09-06  0:19                           ` Stefan Kangas
2022-09-06  2:31                             ` Eli Zaretskii
2022-09-06  3:33                               ` Visuwesh
2022-09-06 12:22                                 ` Eli Zaretskii
2022-09-06 14:02                                   ` Robert Pluim
2022-09-06 14:12                                     ` Eli Zaretskii
2022-09-06 14:20                                       ` Robert Pluim
2022-09-07  1:05                                   ` Stefan Kangas
2022-09-07  2:39                                     ` Eli Zaretskii
2022-09-07  8:18                                       ` Stefan Kangas
2022-09-07 10:34                                         ` Robert Pluim
2022-09-07 11:19                                           ` Eli Zaretskii
2022-09-08  1:47                                             ` Stefan Kangas
2022-09-08  5:59                                               ` Eli Zaretskii [this message]
2022-09-08 12:07                                                 ` Lars Ingebrigtsen
2022-09-08 13:42                                                   ` Eli Zaretskii
2022-09-08 13:46                                                     ` Lars Ingebrigtsen
2022-09-08 14:05                                                       ` Eli Zaretskii
2022-09-08 14:11                                                         ` Lars Ingebrigtsen
2022-09-08 14:15                                                           ` Eli Zaretskii
2022-09-08 14:19                                                             ` Robert Pluim
2022-09-08 16:02                                                               ` Eli Zaretskii
2022-09-09  8:47                                                                 ` Robert Pluim
2022-09-09  9:29                                                                   ` Stefan Kangas
2022-09-09  9:35                                                                     ` Robert Pluim
2022-09-09  9:38                                                                       ` Stefan Kangas
2022-09-09 11:31                                                                   ` Eli Zaretskii
2022-09-06  8:20                             ` Robert Pluim
2022-09-06  8:52                               ` Lars Ingebrigtsen
2022-09-03  1:07                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-03  9:49                   ` Lars Ingebrigtsen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83wnaefltf.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=50849@debbugs.gnu.org \
    --cc=bugs@gnu.support \
    --cc=larsi@gnus.org \
    --cc=rpluim@gmail.com \
    --cc=stefankangas@gmail.com \
    --cc=visuweshm@gmail.com \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).