unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* GnuTLS error -54
@ 2022-06-10 21:36 Stefan Monnier
  2022-06-11  5:18 ` tomas
  2022-06-11 10:44 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Monnier @ 2022-06-10 21:36 UTC (permalink / raw)
  To: emacs-devel

Since yesterday, my attempts to connect to my IMAP server from Gnus tend
to give me a GnuTLS error number -54 (GNUTLS_E_PULL_ERROR, according to
https://www.gnutls.org/manual/html_node/Error-codes.html).

Web searches seem to indicate noone knows what this error is (or more
likely those who do don't write in web-crawled forums) but the general
consensus among the ignoramus (among which I sadly count myself) seems
to be that it's a transient error, and indeed, if I try again a few
times it ends up working.

So I cooked the patch below which seems to do the trick for me.
Without knowing more precisely what's going on, I don't suggest we
should install such a hack, but I'm curious if others have bumped into
such problems, or even better if someone actually knowledgeable might be
able to give his opinion about what might be going on.


        Stefan


diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el
index 6e3845aec1a..7d789b106fb 100644
--- a/lisp/net/gnutls.el
+++ b/lisp/net/gnutls.el
@@ -184,6 +184,7 @@ open-gnutls-stream
 documentation for the specific parameters you can use to open a
 GnuTLS connection, including specifying the credential type,
 trust and key files, and priority string."
+  (named-let try-again ()
   (let* ((parameters
           (cond ((symbolp parameters)
                  (list :nowait parameters))
@@ -209,10 +210,22 @@ open-gnutls-stream
                    :coding (plist-get parameters :coding))))
     (if nowait
         process
-      (gnutls-negotiate :process process
-                        :type 'gnutls-x509pki
-                        :keylist keylist
-                        :hostname (puny-encode-domain host)))))
+      (condition-case err
+          (gnutls-negotiate :process process
+                            :type 'gnutls-x509pki
+                            :keylist keylist
+                            :hostname (puny-encode-domain host))
+        (gnutls-error
+         (if (not (eq (nth 2 err) -54))
+                          (signal (car err) (cdr err))
+                        ;; Error -54 says "error in the pull function" which
+                        ;; doesn't tell me much, but experience suggests it
+                        ;; tends to be the result of a transient network error,
+                        ;; which tends to resolve itself on its own.
+                        (message "GnuTLS error -54 (error in the pull function)")
+                        (sleep-for 1)
+                        (message "GnuTLS error -54; trying again...")
+                        (try-again))))))))
 
 (define-error 'gnutls-error "GnuTLS error")
 




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: GnuTLS error -54
  2022-06-10 21:36 GnuTLS error -54 Stefan Monnier
@ 2022-06-11  5:18 ` tomas
  2022-06-11 10:44 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: tomas @ 2022-06-11  5:18 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]

On Fri, Jun 10, 2022 at 05:36:34PM -0400, Stefan Monnier wrote:
> Since yesterday, my attempts to connect to my IMAP server from Gnus tend
> to give me a GnuTLS error number -54 (GNUTLS_E_PULL_ERROR, according to
> https://www.gnutls.org/manual/html_node/Error-codes.html).
> 
> Web searches seem to indicate noone knows what this error is (or more
> likely those who do don't write in web-crawled forums) but the general
> consensus among the ignoramus (among which I sadly count myself) seems
> to be that it's a transient error, and indeed, if I try again a few
> times it ends up working.

Ignoramus here, too (even possibly ignoramus squared :), but I wanted
to show of the new plaything I stumbled upon. I put GNUTLS_E_PULL_ERROR
into https://sources.debian.org/ yields (among many) this hit, where
that seems to happen:

  https://sources.debian.org/src/gnutls28/3.7.4-2/lib/system/ktls.c/?hl=391#L391

So the meaning seems to be "we received some funny error in recvmsg
which we didin't bother to cach explicitly (the latter being EAGAIN,
EINVAL, EMSGSIZE, EBADMSG). Having a look at which other errors
recvmsg documents, anything is possible, a more harmless being, e.g.
out of memory.

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GnuTLS error -54
  2022-06-10 21:36 GnuTLS error -54 Stefan Monnier
  2022-06-11  5:18 ` tomas
@ 2022-06-11 10:44 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-11 10:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> +      (condition-case err
> +          (gnutls-negotiate :process process
> +                            :type 'gnutls-x509pki
> +                            :keylist keylist
> +                            :hostname (puny-encode-domain host))
> +        (gnutls-error
> +         (if (not (eq (nth 2 err) -54))

Hm...  we already try to loop while handshaking in
gnutls_try_handshake -- would adjusting the looping condition there
work, or is this error reported somewhere else?

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-11 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 21:36 GnuTLS error -54 Stefan Monnier
2022-06-11  5:18 ` tomas
2022-06-11 10:44 ` Lars Ingebrigtsen

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).