Close a could of windows where, if the TLS upcall daemon terminated, the
socket would not be closed properly.
This patch closes these windows by setting the flag that indicates that
a handshake is in progress just when the socket is associated with a
file descriptor for the daemon.