Worked around a problem with select/poll/epoll and gnutls
authorAndrew Tridgell <tridge@samba.org>
Wed, 18 Feb 2009 06:37:45 +0000 (17:37 +1100)
committerAndrew Tridgell <tridge@samba.org>
Wed, 18 Feb 2009 06:37:45 +0000 (17:37 +1100)
commitbb7e6f0f51a91e461c18efd392af3e4fc6174c34
tree266d16a4c8fe1316f1c6c4bfa02f62cb85375bba
parentb1ff79dbb246e717fc4a62c7a615ca7ce9ccc302
Worked around a problem with select/poll/epoll and gnutls

Our packet layer relies on the event system reliably telling us when a
packet is available. When we are using a socket layer like TLS then
things get a bit trickier, as there may be bytes in the encryption
buffer which could be read even if there are no bytes at the socket
level. The GNUTLS library is supposed to prevent this happening by
always leaving some data at the socket level when there is data to be
processed in its buffers, but it seems that this is not always
reliable.

To work around this I have added a new packet option
packet_set_unreliable_select() which tells the packet layer to not
assume that the socket layer has a reliable select, and to instead
keep trying to read from the socket until it gets back no data. This
option is set for the ldap client and server when TLS is negotiated.

This seems to fix the problems with the ldaps tests.
source4/ldap_server/ldap_extended.c
source4/ldap_server/ldap_server.c
source4/lib/stream/packet.c
source4/lib/stream/packet.h
source4/libcli/ldap/ldap_client.c