[python-ldap] Patch for ReconnectLDAPObject
Jonathan Giannuzzi
jonathan at giannuzzi.be
Tue Jun 25 16:45:55 CEST 2013
Hello,
I have found a regression in ReconnectLDAPObject introduced in release 2.4.9 (revision 1.131).
Because of the internal locking, if a connection has been established and bound, then disconnected by the server, the next operation will end in an infinite loop.
That is because reconnect will set self._pending_reconnect to 1 (the lock), then call _apply_last_bind(), which will then call reconnect again, which will then be stuck waiting for self._pending_reconnect to be set back to 0.
I thus changed self._last_bind to use the parent class method, so that it does not call reconnect recursively.
Another failure happened when using the ldappool library, which would call unbind_s() when a connection became invalid. Because self._l was deleted after failing to reconnect, the unbind_s() call would raise an AttributeError exception.
I fixed that by moving the reset of the connection to be done after the raise, so that an exception after unsuccessful reconnects would not mess with self._l.
Finally, there was a change introduced 2 days ago (revision 1.134) where the call to simple_bind_s() in _apply_last_bind() failed with a TypeError.
I fixed it by adding self as first parameter.
Please let me know what you think of those changes.
Thanks & best regards,
Jonathan Giannuzzi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-ldap_reconnect.patch
Type: application/octet-stream
Size: 2085 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20130625/e8d0b1bf/attachment.obj>
More information about the python-ldap
mailing list