emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GnuTLS error -54


From: Stefan Monnier
Subject: GnuTLS error -54
Date: Fri, 10 Jun 2022 17:36:34 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]