From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/63692 Path: news.gmane.org!not-for-mail From: Knut Anders Hatlen Newsgroups: gmane.emacs.gnus.general Subject: [patch] Timeout on IMAP server is not detected Date: Tue, 05 Sep 2006 23:06:33 +0200 Message-ID: <86d5aa81ly.fsf@ugle.hatlen.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1157557107 1928 80.91.229.2 (6 Sep 2006 15:38:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Sep 2006 15:38:27 +0000 (UTC) Original-X-From: ding-owner+m12219@lists.math.uh.edu Wed Sep 06 17:38:26 2006 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GKzSd-0008JJ-08 for ding-account@gmane.org; Wed, 06 Sep 2006 17:37:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1GKzSU-0005gs-00; Wed, 06 Sep 2006 10:36:58 -0500 Original-Received: from nas02.math.uh.edu ([129.7.128.40]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1GKi8s-0003qq-00 for ding@lists.math.uh.edu; Tue, 05 Sep 2006 16:07:34 -0500 Original-Received: from quimby.gnus.org ([80.91.227.211]) by nas02.math.uh.edu with esmtp (Exim 4.52) id 1GKi8q-0007DU-25 for ding@lists.math.uh.edu; Tue, 05 Sep 2006 16:07:34 -0500 Original-Received: from nf-out-0910.google.com ([64.233.182.184]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1GKi8g-000445-00 for ; Tue, 05 Sep 2006 23:07:22 +0200 Original-Received: by nf-out-0910.google.com with SMTP id b2so67089nfe for ; Tue, 05 Sep 2006 14:07:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:from:to:subject:date:message-id:user-agent:mime-version:content-type; b=lewXW0l3ryKX7HBDkDa6YnWiTHRpDDaBPDdLsFK6rv9sibJKDI/yGgIRy4brpehOH1SqR2olj1/2zqKUFUwUwGxcl4ZrDXHj/tsowe3FFUA33MkVWev3C81lCWmuGH7iNzXQwRDp3QalUT0y91sHO4JxnO5svXJ8Wy4G42zXMNA= Original-Received: by 10.49.10.3 with SMTP id n3mr8295936nfi; Tue, 05 Sep 2006 14:07:22 -0700 (PDT) Original-Received: from localhost ( [193.71.105.147]) by mx.gmail.com with ESMTP id a23sm11855508nfc.2006.09.05.14.07.21; Tue, 05 Sep 2006 14:07:22 -0700 (PDT) Original-To: ding@gnus.org User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.3 (berkeley-unix) X-Spam-Score: -2.4 (--) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:63692 Archived-At: --=-=-= 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 --=-=-= Content-Disposition: attachment; filename=ping.diff 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. --=-=-=--