From 76b52f35ba35be09d3b15184f062e91c2fe9fb56 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 3 Nov 2011 22:11:57 +0000 Subject: [PATCH] nnimap.el (nnimap-open-connection-1): Use tcp-keealive if possible. --- lisp/ChangeLog | 4 ++++ lisp/nnimap.el | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e8d44de1b..0d7d3927f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -6,6 +6,10 @@ * message.el (message-send-and-exit): Document `arg'. +2011-11-03 Stefan Monnier + + * nnimap.el (nnimap-open-connection-1): Use tcp-keealive if possible. + 2011-11-02 Teodor Zlatanov * gnus-sync.el: More commentary about `gnus-sync-read' issues. diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 77372c246..cda17ba57 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -397,6 +397,14 @@ textual parts.") (stream-type (plist-get props :type))) (when (and stream (not (memq (process-status stream) '(open run)))) (setq stream nil)) + + (when (and (fboundp 'set-network-process-option) ;; Not in XEmacs. + (fboundp 'process-type) ;; Emacs 22 doesn't provide it. + (eq (process-type stream) 'network)) + ;; Use TCP-keepalive so that connections that pass through a NAT + ;; router don't hang when left idle. + (set-network-process-option stream :keepalive t)) + (setf (nnimap-process nnimap-object) stream) (setf (nnimap-stream-type nnimap-object) stream-type) (if (not stream) -- 2.34.1