GNU bug report logs - #32452
26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy

Previous Next

Package: emacs;

Reported by: Noam Postavsky <npostavs <at> gmail.com>

Date: Thu, 16 Aug 2018 12:14:01 UTC

Severity: minor

Tags: moreinfo

Found in version 26.1

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 32452 <at> debbugs.gnu.org
Subject: bug#32452: 26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
Date: Tue, 24 Sep 2019 07:39:08 +0200
Noam Postavsky <npostavs <at> gmail.com> writes:

> +  enum { MAX_DELAY_NS = 100 * 1000 * 1000 }; // Max 100ms delay.
> +  struct timespec delay = { 0, 1000 };
>    do
>      {
>        ret = gnutls_handshake (state);
> @@ -558,7 +560,9 @@ gnutls_try_handshake (struct Lisp_Process *proc)
>      }
>    while (ret < 0
>  	 && gnutls_error_is_fatal (ret) == 0
> -	 && ! non_blocking);
> +	 && ! non_blocking
> +         && (nanosleep (&delay, NULL),
> +             delay.tv_nsec = min (delay.tv_nsec * 2, MAX_DELAY_NS)));

This code has changed somewhat since the proposed patch:

  while ((ret = gnutls_handshake (state)) < 0)
    {
      do
	ret = gnutls_handshake (state);
      while (ret == GNUTLS_E_INTERRUPTED);

      if (0 <= ret || emacs_gnutls_handle_error (state, ret) == 0
	  || non_blocking)
	break;
      maybe_quit ();
    }

But perhaps adding some sleep here would be a good idea, anyway.  On the
other hand, 100ms seems way too long -- that's a noticeable slow-down in
network set-up.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 3 years and 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.