Throw away broken connections

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Ethan Glasser-Camp 2011-03-08 10:05:24 -05:00 committed by Nicolas Sebrecht
parent 197030da1a
commit a139d9deed

View File

@ -154,6 +154,10 @@ class IMAPServer:
"""Releases a connection, returning it to the pool.""" """Releases a connection, returning it to the pool."""
self.connectionlock.acquire() self.connectionlock.acquire()
self.assignedconnections.remove(connection) self.assignedconnections.remove(connection)
# Don't reuse broken connections
if connection.Terminate:
connection.logout()
else:
self.availableconnections.append(connection) self.availableconnections.append(connection)
self.connectionlock.release() self.connectionlock.release()
self.semaphore.release() self.semaphore.release()