IMAP IDLE cleanup(5): Really discard connections when they are dropped
Finally, actually discard dropped connections when we detect them as an imapobj.abort() has been thrown. In this case, invoke releaseconnection with drop_conn=True. We don't need the self.aborted attribute to get signified of dropped connections. An Execption during the noop will do. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
59753fc06f
commit
ce8471a011
@ -505,18 +505,13 @@ class IdleThread(object):
|
|||||||
connections, or c) the standard imaplib IDLE timeout of 29
|
connections, or c) the standard imaplib IDLE timeout of 29
|
||||||
minutes kicks in."""
|
minutes kicks in."""
|
||||||
result, cb_arg, exc_data = args
|
result, cb_arg, exc_data = args
|
||||||
if exc_data is None:
|
if exc_data is None and not self.stop_sig.isSet():
|
||||||
if not self.stop_sig.isSet():
|
# No Exception, and we are not supposed to stop:
|
||||||
self.needsync = True
|
self.needsync = True
|
||||||
self.stop_sig.set()
|
self.stop_sig.set() # continue to sync
|
||||||
else:
|
|
||||||
# We got an "abort" signal.
|
|
||||||
self.imapaborted = True
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
while not self.stop_sig.isSet():
|
while not self.stop_sig.isSet():
|
||||||
self.needsync = False
|
self.needsync = False
|
||||||
self.imapaborted = False
|
|
||||||
|
|
||||||
success = False # successfully selected FOLDER?
|
success = False # successfully selected FOLDER?
|
||||||
while not success:
|
while not success:
|
||||||
@ -527,7 +522,7 @@ class IdleThread(object):
|
|||||||
if e.severity == OfflineImapError.ERROR.FOLDER_RETRY:
|
if e.severity == OfflineImapError.ERROR.FOLDER_RETRY:
|
||||||
# Connection closed, release connection and retry
|
# Connection closed, release connection and retry
|
||||||
self.ui.error(e, exc_info()[2])
|
self.ui.error(e, exc_info()[2])
|
||||||
self.parent.releaseconnection(imapobj)
|
self.parent.releaseconnection(imapobj, True)
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
else:
|
else:
|
||||||
@ -539,13 +534,16 @@ class IdleThread(object):
|
|||||||
"Sleep until next refresh cycle." % imapobj.identifier)
|
"Sleep until next refresh cycle." % imapobj.identifier)
|
||||||
imapobj.noop()
|
imapobj.noop()
|
||||||
self.stop_sig.wait() # self.stop() or IDLE callback are invoked
|
self.stop_sig.wait() # self.stop() or IDLE callback are invoked
|
||||||
if self.stop_sig.isSet():
|
try:
|
||||||
# Can't NOOP on a bad connection.
|
# End IDLE mode with noop, imapobj can point to a dropped conn.
|
||||||
if not self.imapaborted:
|
imapobj.noop()
|
||||||
imapobj.noop()
|
except imapobj.abort():
|
||||||
# We don't do event.clear() so that we'll fall out
|
self.ui.warn('Attempting NOOP on dropped connection %s' % \
|
||||||
# of the loop next time around.
|
imapobj.identifier)
|
||||||
self.parent.releaseconnection(imapobj)
|
self.parent.releaseconnection(imapobj, True)
|
||||||
|
else:
|
||||||
|
self.parent.releaseconnection(imapobj)
|
||||||
|
|
||||||
if self.needsync:
|
if self.needsync:
|
||||||
# here not via self.stop, but because IDLE responded. Do
|
# here not via self.stop, but because IDLE responded. Do
|
||||||
# another round and invoke actual syncing.
|
# another round and invoke actual syncing.
|
||||||
|
Loading…
Reference in New Issue
Block a user