Dear Folks,

We use a lot of busy OpenLDAP servers and a lot of Perl, with
persistent Net::LDAP connections to the servers.  The problem is:
How good is the connection to the server?

I found that:

{
    my $ldap;
    sub ldapopen {
        if ( not $ldap ) {
            $ldap = Net::LDAP->new('localhost');
        }
        return $ldap;
    }
}

doesn't work to determine the viability of the connection.  Truth is
insufficient.
So next we tried
if ( not $ldap or not $ldap->socket ) {
   ...
}

and still this didn't catch timed out connections.

Now we are doing things like this:
[$BASE is the DN of the top-level "suffix" entry]

{
    my $ldap;
    if ( $ldap and $ldap->socket ) {
        my $result = $ldap->search(
            base => $BASE,
            scope => 'base',
            filter => '(objectClass=*)',
        );
        loginfo "Testing result of search for $BASE";
        if ( $result and not $result->code ) {
            return $ldap if $result->count() == 1;
        }
    }
    loginfo '(Re)connecting to LDAP server';
    $ldap = Net::LDAP->new( 'localhost' );
    return $ldap;
}

which is two searches for one, rather overkill.

Radiator, the Perl RADIUS server from open.com uses a rather complex
piece of code to check the life of the socket.

How does everyone else cope with this problem?

If we use non-persistent connections, then we run out of TCP sockets
under heavy load.
--
Nick Urbanik http://nicku.org 808-71011 nick.urba...@optusnet.com.au
GPG: 7FFA CDC7 5A77 0558 DC7A 790A 16DF EC5B BB9D 2C24  ID: BB9D2C24
I disclaim, therefore I am.

Attachment: pgpZu0rBEcLOd.pgp
Description: PGP signature

Reply via email to