imapserver: Make noop() more resitent against dropped connections.

Drop a connection, if the NOOP to keep a connection open fails due to
broken connections.

Note that I believe this function is not working as intended. We grab
one random connection and send a NOOP. This is not enough to keep all
connections open, and if we invoke this function multiple times, we
might well always get the same connection to send a NOOP through.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-10-05 18:18:55 +02:00
parent e707bc530b
commit 76b0d7cf25
2 changed files with 20 additions and 3 deletions

View File

@ -32,3 +32,6 @@ Bug Fixes
* New folders on the remote would be skipped on the very sync run they * New folders on the remote would be skipped on the very sync run they
are created and only by synced in subsequent runs. Fixed. are created and only by synced in subsequent runs. Fixed.
* Make NOOPs to keep a server connection open more resistant against dropped
connections.

View File

@ -491,10 +491,24 @@ class IdleThread(object):
self.thread.join() self.thread.join()
def noop(self): 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 = self.parent.acquireconnection()
try:
imapobj.noop() imapobj.noop()
self.stop_sig.wait() 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.parent.releaseconnection(imapobj)
self.stop_sig.wait() # wait until we are supposed to quit
def dosync(self): def dosync(self):
remoterepos = self.parent.repos remoterepos = self.parent.repos