Socket: Fix race condition in SSL handshakes.