Fix some deadlocks in the TlsStream class.