all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: gnutls infloop possibly fixed
Date: Sat, 11 Feb 2012 21:48:08 -0500	[thread overview]
Message-ID: <87ehu0lqc7.fsf@lifelogs.com> (raw)
In-Reply-To: <87hayx8feo.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 11 Feb 2012 18:10:23 +0100")

On Sat, 11 Feb 2012 18:10:23 +0100 Lars Ingebrigtsen <larsi@gnus.org> wrote: 

LI> I finally took a hard look at the GnuTLS-related Emacs hangs.  It turned
LI> out to be pretty easy to reproduce for me.  If I switch off the wifi on
LI> this laptop and then presses `g' in Gnus, Emacs would reliably use 100%
LI> CPU, and `C-g' or anything wouldn't work.  So a totally dead Emacs.

LI> I chased this down to emacs_gnutls_write, which would just, well,
LI> infloop if libgnutls returned EAGAIN.  I've now removed that, and just
LI> leaves the normal Emacs process loop to retry if we get an EAGAIN.

LI> This seems to work for me -- `C-g' reliably works for me if I drop the
LI> network, or I get a new IP address.

LI> There may be other side-effects, though.  Slower throughput?  I don't
LI> know.  Please give it a whirl and report back whether things stop
LI> working or not.

Thanks!  I have just one question: can we, instead of aborting on
EAGAIN, retry a few times?  My suggestion is below.  Maybe we could wait
a millisecond, too.  Or is all that handled at the Emacs process loop
level?

Thanks
Ted

=== modified file 'src/gnutls.c'
--- src/gnutls.c        2012-02-11 17:06:14 +0000
+++ src/gnutls.c        2012-02-12 02:46:24 +0000
@@ -341,6 +341,7 @@
 EMACS_INT
 emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, EMACS_INT nbyte)
 {
+  int retries = 10;
   ssize_t rtnval = 0;
   EMACS_INT bytes_written;
   gnutls_session_t state = proc->gnutls_state;
@@ -365,6 +366,8 @@
        {
          if (rtnval == GNUTLS_E_INTERRUPTED)
            continue;
+          if (rtnval == GNUTLS_E_AGAIN && retries-- > 0)
+           continue;
          else
            break;
        }



  reply	other threads:[~2012-02-12  2:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-11 17:10 gnutls infloop possibly fixed Lars Ingebrigtsen
2012-02-12  2:48 ` Ted Zlatanov [this message]
2012-02-12 19:47   ` Lars Ingebrigtsen
2012-02-12 21:34     ` Ted Zlatanov
2012-02-13 15:48     ` Tom Tromey
2012-02-13 19:11       ` Lars Ingebrigtsen
2012-02-13 19:39         ` Lars Ingebrigtsen
2012-02-13 20:46           ` Andreas Schwab
2012-02-13 20:47             ` Lars Ingebrigtsen
2012-02-13 21:41     ` Richard Stallman
2012-02-13 22:05       ` Andreas Schwab

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=87ehu0lqc7.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=emacs-devel@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.