Allow SSL connections to send keep-alive messages

This seems to prevent mysterious hangs with SSL imap servers (especially
gmail?) and does not harm in any case. So let us enable keep-alive
messages for ssl connections.
Our thread pool should be made more robust against closed SSL
connections (which do not always seem to raise Exceptions), and not
deadlock while waiting for resources or data that will never arrive.

Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Signed-off-by: Gábor Melis <mega@retes.hu>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Gábor Melis 2011-03-01 14:49:02 +01:00 committed by Nicolas Sebrecht
parent 838a67bc40
commit 966841c8d6
2 changed files with 6 additions and 0 deletions

View File

@ -23,6 +23,8 @@ Changes
Bug Fixes
---------
* Allow SSL connections to send keep-alive messages.
Pending for the next major release
==================================

View File

@ -110,6 +110,10 @@ class WrappedIMAP4_SSL(IMAP4_SSL):
# FIXME
raise socket.error(last_error)
# Allow sending of keep-alive message seems to prevent some servers
# from closing SSL on us leading to deadlocks
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
#connected to socket, now wrap it in SSL
try:
if self._cacertfile: