diff --git a/Changelog.draft.rst b/Changelog.draft.rst index 7982706..1f6b46b 100644 --- a/Changelog.draft.rst +++ b/Changelog.draft.rst @@ -32,3 +32,6 @@ Bug Fixes * New folders on the remote would be skipped on the very sync run they are created and only by synced in subsequent runs. Fixed. + +* Make NOOPs to keep a server connection open more resistant against dropped + connections. diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index ef54e31..7006ef9 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -491,10 +491,24 @@ class IdleThread(object): self.thread.join() def noop(self): + #TODO: AFAIK this is not optimal, we will send a NOOP on one + #random connection (ie not enough to keep all connections + #open). In case we do the noop multiple times, we can well use + #the same connection every time, as we get a random one. This + #function should IMHO send a noop on ALL available connections + #to the server. imapobj = self.parent.acquireconnection() - imapobj.noop() - self.stop_sig.wait() - self.parent.releaseconnection(imapobj) + try: + imapobj.noop() + except imapobj.abort: + self.ui.warn('Attempting NOOP on dropped connection %s' % \ + imapobj.identifier) + self.parent.releaseconnection(imapobj, True) + imapobj = None + finally: + if imapobj: + self.parent.releaseconnection(imapobj) + self.stop_sig.wait() # wait until we are supposed to quit def dosync(self): remoterepos = self.parent.repos