gnutls: fix a hang when closing during handshake
authorDan Winship <danw@gnome.org>
Fri, 7 Dec 2012 14:37:22 +0000 (15:37 +0100)
committerDan Winship <danw@gnome.org>
Sun, 9 Dec 2012 15:31:56 +0000 (16:31 +0100)
commit10181f38be83773ee27cc4afae9a4d3d92f7763b
tree125da2400593e07bbee6d7ec894902a6eaf5eba4
parentc8a597e2ed8e181fd65ef3b777fe010d7409093b
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
tls/gnutls/gtlsconnection-gnutls.c
tls/tests/connection.c