gnutls: fix a hang when closing during handshake
If the app did a synchronous g_io_stream_close() on a connection that
had completed an async handshake but not yet run finish_handshake(),
it would hang forever (because the close would be blocking the main
loop that finish_handshake() was going to run in, and it couldn't
continue until finish_handshake() ran).
Fix this by yielding the handshake op from the end of the handshake
thread, and then in async_handshake_completed(), deal with the
possibility that someone else might have already run
finish_handshake() for us.
Add a test for this to tls/tests/connection. This patch also disables
the refcount checking on test->client_connection for now, because the
new code makes it racy; it's possible we'll run teardown_connection()
before the handshake GTask has dropped its ref on the connection.
https://bugzilla.gnome.org/show_bug.cgi?id=688751