How to detect a client-closed connection during a write from our LDAP server?

Isaac Boukris iboukris at
Fri Sep 30 11:11:41 UTC 2022

On Fri, 2022-09-30 at 14:26 +1300, Andrew Bartlett via samba-technical
> I've been trying to chase down the CPU spins reported by our users in
> the writev() codepath from our LDAP server.
> A private mail the the strace output shows the sockets are in
> CLOSE_WAIT state, returning EAGAIN over and over (after a call to
> epoll() each time).  That alone would be enough to keep things
> spinning.
> But they are being shut down, however our LDAP server won't be
> triggering a read any time soon, it is waiting to flush the response
> out.

Why wouldn't it? I mean why does the read waits for the write? if epoll
says so then we should read, then we may detect that the client closed
it end and may decide to give up the writes.

Technically, I think there is no problem to write to a socket after the
peer sent us FIN, it just mean he closed its end and won't write no
more, but we can still write until we close or he/we reset (as is the
case with HTTP 1.0).

More information about the samba-technical mailing list