--- kdepimlibs-4.10.4/kimap/sessionthread.cpp.kimap_recursion 2013-05-28 21:26:23.000000000 +0200 +++ kdepimlibs-4.10.4/kimap/sessionthread.cpp 2013-06-05 12:39:24.194506980 +0200 @@ -24,6 +24,8 @@ #include +#include + #include "imapstreamparser.h" #include "message_p.h" #include "session.h" @@ -39,7 +41,9 @@ : QThread(), m_hostName( hostName ), m_port( port ), m_session( parent ), m_socket( 0 ), m_stream( 0 ), m_mutex( QMutex::Recursive ), m_encryptedMode( false ), - triedSslVersions( 0 ), doSslFallback( false ) + triedSslVersions( 0 ), + doSslFallback( false ), + m_alreadyHandlingErrors( false ) { // Yeah, sounds weird, but QThread object is linked to the parent // thread not to itself, and I'm too lazy to introduce yet another @@ -222,12 +226,14 @@ } else { QMetaObject::invokeMethod( m_session, "socketDisconnected" ); } + m_alreadyHandlingErrors = false; } void SessionThread::socketError() { QMutexLocker locker( &m_mutex ); - if ( doSslFallback ) { + if ( doSslFallback && !m_alreadyHandlingErrors ) { + m_alreadyHandlingErrors = true; locker.unlock(); // disconnectFromHost() ends up calling reconnect() m_socket->disconnectFromHost(); } else { --- kdepimlibs-4.10.4/kimap/sessionthread_p.h.kimap_recursion 2013-05-28 21:26:23.000000000 +0200 +++ kdepimlibs-4.10.4/kimap/sessionthread_p.h 2013-06-05 10:58:46.855926317 +0200 @@ -82,6 +82,7 @@ bool m_encryptedMode; KTcpSocket::SslVersions triedSslVersions; bool doSslFallback; + bool m_alreadyHandlingErrors; }; }