Hmmm. I just wrote a small test client which opens a large number of connections to the LDAP server and then closes them again. (It issues an anonymous search as well.) I encountered a server hang at around 2050 connections, stuck in the WAKE_LISTENER macro. Apparently when a large number of connections closes in rapid succession like this the pipe that's used for waking the listener gets full.
I note that our definition of WAKE_LISTENER has an #if case for NO_THREADS / GNU_PTH in which case it doesn't write anything into the pipe if a flag "waking" is already set. When I use this version on the pthreads build, the hang at 2050 closes disappears. It seems we need this waking test by default.
Watch out, IIRC, there is a race condition in there (which
we avoided by sending multiple wakes).