Subject: | Missing destructor |
Date: | Tue, 08 May 2018 10:30:42 +0200 |
To: | bug-Net-LDAPxs [...] rt.cpan.org |
From: | Philippe Causse <filimus [...] icloud.com> |
Hello,
As a suggestion for improvement, it would be nice if you had a destructor to call unbind(), so that it follows other common behaviours (i.e. auto-close for IO::Handles, DBI handles etc…).
I was expecting that when my $ldap object goes out of scope, the LDAP session would be closed.
That was not the case unfortunately and after some time , I noticed an accumulation of sockets on the process (half-closed TCP connections).
As a workaround, I just did:
sub Net::LDAPxs::DESTROY {
my $self = shift;
eval { $self->unbind() } if defined $self;
}
Also, if the API is not thread-safe, then probably adding a
sub Net::LDAPxs::CLONE_SKIP { 1 }
would be a good idea too. I haven’t checked for thread-safety though…
Best regards,
/Phil.