Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] Timeout on IMAP server is not detected
@ 2006-09-05 21:06 Knut Anders Hatlen
  0 siblings, 0 replies; only message in thread
From: Knut Anders Hatlen @ 2006-09-05 21:06 UTC (permalink / raw)


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

Hi,

I have experienced problems with Gnus not detecting that the (SSL or
TLS) connection to the IMAP server has timed out.  This can cause many
different symptoms, for instance marks not being updated when leaving
the summary buffer, sent mail not being copied to sent-mail folder and
annoying messages about "no IMAP process".

The problem seems to be that imap-opened only checks whether the IMAP
process is still open and running. When the server times out, the
openssl or gnutls-cli process isn't terminated until it actually tries
to send a command to the server. Therefore, imap-opened returns t, and
no attempt to reconnect is made before the command is sent.

The attached patch adds a function, imap-ping-server, which pings the
server with a NOOP command and returns non-nil iff the server
responds. Additionally, imap-opened is extended with a call to the
ping function. With this patch, Gnus reconnects instead of failing
when the server has timed out.

-- 
Knut Anders

[-- Attachment #2: ping.diff --]
[-- Type: text/plain, Size: 984 bytes --]

Index: lisp/imap.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/imap.el,v
retrieving revision 7.29
diff -u -r7.29 imap.el
--- lisp/imap.el	26 Jun 2006 12:08:33 -0000	7.29
+++ lisp/imap.el	4 Sep 2006 17:45:39 -0000
@@ -1142,7 +1142,16 @@
        (buffer-live-p buffer)
        (with-current-buffer buffer
 	 (and imap-process
-	      (memq (process-status imap-process) '(open run))))))
+	      (memq (process-status imap-process) '(open run))
+	      (imap-ping-server)))))
+
+(defun imap-ping-server (&optional buffer)
+  "Ping the imap server in BUFFER with a noop command. Return non-nil
+if the server responds, and nil if it does not respond. If BUFFER is
+nil, the current buffer is used."
+  (condition-case ()
+      (imap-ok-p (imap-send-command-wait "NOOP" buffer))
+    (error nil)))
 
 (defun imap-authenticate (&optional user passwd buffer)
   "Authenticate to server in BUFFER, using current buffer if nil.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-05 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-05 21:06 [patch] Timeout on IMAP server is not detected Knut Anders Hatlen

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 NNTP newsgroup(s).