[Date Prev][Date Next]
Re: connection pooling in back-ldap?
From: "Howard Chu" <firstname.lastname@example.org>
Date: Mon, 14 Oct 2002 11:28:55 -0700
Just a note - this is actually a fairly intensive project, because it
requires additional multi-threading support in libldap_r that hasn't been
implemented yet. Specifically, pooling multiple incoming operations onto a
single LDAP session requires libldap_r to allow a single LDAP session to be
used by any number of threads concurrently. At present, this capability
doesn't exist. You might get around this using mutexes in back-ldap to
protect each access to an LDAP session, but I haven't looked into it.
It probably makes more sense to do this outside of libldap_r.
back-ldap could maintain a list of LDAP connections, each with an
associated mutex. When a request comes in, the servicing thread calls
pthread_mutex_trylock() on each current connection, and if it succeeds
uses that connection (possibly refreshing it if has closed).
If there are no available connections, it grabs a connection creation
lock and adds a new connection to the list.
Making a single libldap_r handle reentrant requires internal locking
(since clearly two threads can't write to a TCP socket
simultaneously), and might lead to unexpected performance problems.