Ensure that timeouts apply to TCP socket connexions.
commit842ca62336cd44b6ed1add2c93bf7a7649c58f08
authorRoland C. Dowdeswell <elric@imrryr.org>
Thu, 12 Jul 2012 00:00:23 +0000 (12 01:00 +0100)
committerRoland C. Dowdeswell <elric@imrryr.org>
Thu, 12 Jul 2012 00:00:23 +0000 (12 01:00 +0100)
tree8945c34d2e597663f77e561a05d7629a1baf2ffc
parent7aaeafb72b1e22502ab135f563f680ae953898c3
Ensure that timeouts apply to TCP socket connexions.

Currently the Heimdal code calls connect(2) on TCP connexions to
the KDC without setting O_NONBLOCK.  This code implements a
timed_connect() function which will in the case of SOCK_STREAM
sockets put the socket into non-blocking mode prior to calling
connect and use select(2) to apply the configured timeout to connect
completion.  This does not entirely solve the problem of potential
timeouts in the code as it is still possible to block while writing
to the socket.  A proper implementation would also likely start
new connexions after a short interval before timing out existing
connexions and return the results from the first KDC which successfully
responds but we did not do that yet.

This patch is from heimdal-1-5-branch patches:

5b55e4429caed27b32aac4bc5930f2672a43f273
6b66321b271ee4672e70ad349ec796dd755cf897
2e12c7f3e8dca7e1696ebd92199617ce413565e7

Squashed together along with a quick shadowed variable warning fix
to allow it to compile with --enable-developer.
lib/krb5/krb5_locl.h
lib/krb5/send_to_kdc.c