Howard Chu writes:
We listen for writable sockets if a write attempt returns incomplete.
There's
a pair of mutexes and condition variables used to synch up here between the
writing threads and the listener thread. It's quite a lot of lock overhead. As
far as I can tell the main reason we do this is so that we can stop a writer
thread on demand instead of having it just block forever in write().
slapd seems to use non-blocking socket descriptors if it can, so it's
rather that write() to a full socket would otherwise do a busy loop
write()ing 0 bytes until there was room.
I wonder if slapd can use blocking sockets? Then it could shutdown()
the descriptor to force a blocked write() call to terminate. Unless
there are times when one would want to write something else to the
socket instead - some TLS magic, maybe...
connection_init() does seem to believe slapd can deal with blocking
sockets, since it tests for fcntl NONBLOCK failure but proceeds instead
of aborting the connection.
--
Hallvard