Ticket #48122 nunc-stans FD leak
https://fedorahosted.org/389/ticket/48122
Reviewed by: mreynolds (Thanks!)
Branch: master
Fix Description: Added a lot of debugging when using CONNS level. Note
that it alters the timing considerably, so it should only be used when
trying to get a general trace of the code, not when performance is an
issue at all.
Instead of scheduling a closure job when the connection is made
readable, wait until the refcnt drops to 1 and the connection is in
the CLOSING state to avoid having dueling closure jobs.
The timeout interval for closure jobs is now the same as the old
slapi_wakeup_timer to avoid tight loops.
Instead of relying on more_data to still be true at the end of
connection_threadmain, check the buffer directly to see if there
is any buffered data, because another thread may have drained the
buffer out from under this thread. Added a new convenience
function conn_buffered_data_avail_nolock() because the buffer size
is checked in multiple places.
Do not bypass poll in connection_threadmain when using nunc-stans
because it kills performance, spending a lot of time doing the
poll() in connection_read_operation(). Similarly in
ns_handle_new_connection - do not call ns_handle_pr_read_ready, but
instead put the new connection back into nunc-stans and only notify
ns_handle_pr_read_ready when the new connection is ready for read.
In some cases, the new connection is not ready for read right away,
and would end up in the poll() in connection_read_operation().
Platforms tested: Fedora 20, EL7
Flag Day: no
Doc impact: no