1
0
mirror of https://github.com/OfflineIMAP/offlineimap.git synced 2024-07-08 09:20:52 +02:00

Make releaseconnection a NOOP when conn is None

During cleanup we often call releaseconnection in a finally: block. But
in cases of error, we might have dropped the connection earlier already
and set it to "None". In this case don't fail releaseconnection() but
make it a NOOP.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-11-02 10:34:45 +01:00
parent 8b3ed8b004
commit 3aded16ed4

View File

@ -113,6 +113,7 @@ class IMAPServer:
:param drop_conn: If True, the connection will be released and :param drop_conn: If True, the connection will be released and
not be reused. This can be used to indicate broken connections.""" not be reused. This can be used to indicate broken connections."""
if connection is None: return #noop on bad connection
self.connectionlock.acquire() self.connectionlock.acquire()
self.assignedconnections.remove(connection) self.assignedconnections.remove(connection)
# Don't reuse broken connections # Don't reuse broken connections