gnutls: handle simultaneous ops, do handshaking in a thread
authorDan Winship <danw@gnome.org>
Mon, 2 Jul 2012 16:58:02 +0000 (12:58 -0400)
committerDan Winship <danw@gnome.org>
Wed, 18 Jul 2012 21:46:11 +0000 (17:46 -0400)
commit54b77031a17aa531d6139f668aeb8932bdee94f9
tree7e524f72daee8eed33fe46a01a02a2bb16eb57b2
parente4e47d270eaeacef010a9ee41c8a3f1c0aabdad6
gnutls: handle simultaneous ops, do handshaking in a thread

Keep separate internal read/write states so that you can do
simultaneous reads/writes (either simultaneous async ops in the same
thread, or simultaneous sync ops in different threads). Add
locking/blocking so that this works correctly even in the presence of
rehandshakes (and add test cases for this).

As part of this, change handshaking so that the I/O part of it always
happens in a separate thread, which has three advantages:

  1. It simplifies GTlsConnectionGnutlsSource by making it not have to
     worry about flipping back and forth between read and write.

  2. (Future) It will let the caller asynchronously handle
     certificate-related functionality that is implemented via
     synchronous callbacks in gnutls.

  3. (Future) We can use g_task_set_return_on_cancel() to allow
     cancellation even during uncancellable PKCS#11 operations.

https://bugzilla.gnome.org/show_bug.cgi?id=656343
https://bugzilla.gnome.org/show_bug.cgi?id=660252
tls/gnutls/gtlsconnection-gnutls.c
tls/tests/connection.c