Skip to content

Commit d7b80de

Browse files
committed
Claim ownership of socket once we've passed it to libldap
Fixes: #460 Closes: #543
1 parent 2229d83 commit d7b80de

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

Tests/t_ldapobject.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -647,24 +647,14 @@ def test105_reconnect_restore(self):
647647
@requires_init_fd()
648648
class Test03_SimpleLDAPObjectWithFileno(Test00_SimpleLDAPObject):
649649
def _open_ldap_conn(self, who=None, cred=None, **kwargs):
650-
if hasattr(self, '_sock'):
651-
raise RuntimeError("socket already connected")
652-
self._sock = socket.create_connection(
650+
sock = socket.create_connection(
653651
(self.server.hostname, self.server.port)
654652
)
655-
return super()._open_ldap_conn(
656-
who=who, cred=cred, fileno=self._sock.fileno(), **kwargs
653+
result = super()._open_ldap_conn(
654+
who=who, cred=cred, fileno=sock.fileno(), **kwargs
657655
)
658-
659-
def tearDown(self):
660-
self._sock.close()
661-
delattr(self, '_sock')
662-
super().tearDown()
663-
664-
def reset_connection(self):
665-
self._sock.close()
666-
delattr(self, '_sock')
667-
super(Test03_SimpleLDAPObjectWithFileno, self).reset_connection()
656+
sock.detach()
657+
return result
668658

669659

670660
if __name__ == '__main__':

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy