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

Andrew Bartlett abartlet at
Fri Sep 30 01:26:28 UTC 2022

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

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

Technically even after our server OS has got the FIN, there is
potentially data in the read buffer (so a read() might not return 0
anyway), but perhaps most of the time that would be 0.

So how can we detect this?  Can we at least put a timeout on a writev()
call via tsocket et al?  If so, how do we do that?

Mailing list threads:

Andrew Bartlett
Andrew Bartlett (he/him)
Samba Team Member (since 2001)
Samba Team Lead, Catalyst IT

Samba Development and Support, Catalyst IT - Expert Open Source

More information about the samba-technical mailing list