all messages for Emacs-related lists mirrored at yhetil.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

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