[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: connection management changes



Hallvard Breien Furuseth wrote:
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.

My point was that it would have been simpler all around to use a blocking descriptor and let write() sit and wait, except for the fact that we need the ability to stop it from waiting.

Of course we also want it to be non-blocking when we read, though we could use ioctl(FIONREAD) instead.

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.



--
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/