GNU bug report logs -
#32452
26.1; gnutls_try_handshake maxes out cpu retrying when server is a bit busy
Previous Next
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
Eli Zaretskii <eliz <at> gnu.org> writes:
> In which case it's fine, we just need to do something in the loop to
> yield the CPU, like some nanosleep, perhaps? And maybe enlarge the
> sleep period as time goes on?
>
> debbugs is terribly slow in a browser as well, right now. But
> hundreds of attempts sounds excessive to me.
The debbugs server seems back to normal speeds now, I'm getting ~200
hits with it just like other servers. The patch below brings it down to
15~20. nanosleep isn't portable though right? Not sure what to put
instead, it seems existing wait functions in Emacs are all tied up with
threads and processes, so I don't know if it's safe to call them here.
--- i/src/gnutls.c
+++ w/src/gnutls.c
@@ -550,6 +550,8 @@ gnutls_try_handshake (struct Lisp_Process *proc)
if (non_blocking)
proc->gnutls_p = true;
+ 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)));
proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
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.