allow to call ldap2.destroy_connection multiple times

A regression fix.

Reviewed-By: Nathaniel McCallum <npmccallum@redhat.com>
This commit is contained in:
Petr Vobornik 2015-04-23 12:03:49 +02:00
parent b88f5333ec
commit 7d10547ae3
2 changed files with 4 additions and 3 deletions

View File

@ -1089,7 +1089,7 @@ class LDAPClient(object):
"""
with self.error_handler():
self._flush_schema()
self.conn.unbind_s()
self._conn.unbind_s()
def make_dn_from_attr(self, attr, value, parent_dn=None):
"""

View File

@ -196,8 +196,9 @@ class ldap2(LDAPClient, CrudBackend):
def destroy_connection(self):
"""Disconnect from LDAP server."""
try:
self.unbind()
LDAPClient._disconnect(self)
if self._conn is not None:
self.unbind()
LDAPClient._disconnect(self)
except errors.PublicError:
# ignore when trying to unbind multiple times
pass