GNOME Bugzilla – Bug 689271
gnutls: Don't hang trying to handshake, if early close
Last modified: 2012-12-21 14:24:52 UTC
When trying to close a GTlsConnectionGnutls early before handshakeing, the code assumed 'need_handshake' and would do an implicit handshake before closing. This could lead to hangs on closing a connection, if the server isn't responsive, and is generally useless.
Created attachment 230179 [details] [review] gnutls: Don't hang trying to handshake, if early close When closing a connection before the handshake, the GTlsConnectionGnutls code would try to do a handshake. Fix this, and test for it.
Created attachment 230184 [details] [review] gnutls: Don't hang trying to handshake, if early close Minor fix, don't use the echo test server.
Comment on attachment 230184 [details] [review] gnutls: Don't hang trying to handshake, if early close >+ /* If closing, then no need to complete a handshake */ >+ gnutls->priv->need_handshake = FALSE; >+ > if (!claim_op (gnutls, G_TLS_CONNECTION_GNUTLS_OP_CLOSE, > TRUE, cancellable, error)) Hm... should that go after the claim_op?
claim_op() is the one that acts on need_handshake. But if you want to solve another way, you could make claim_op not respect need_handshake if G_TLS_CONNECTION_GNUTLS_OP_CLOSE. Up to you.
(In reply to comment #4) > claim_op() is the one that acts on need_handshake. oh, right > But if you want to solve another way, you could make claim_op not respect > need_handshake if G_TLS_CONNECTION_GNUTLS_OP_CLOSE. Up to you. Yeah, there's a race condition in your patch, since another thread might try to start an op in between when you set need_handshake FALSE and when you claim OP_CLOSE.
Created attachment 230242 [details] [review] gnutls: Don't hang trying to handshake, if early close When closing a connection before the handshake, the GTlsConnectionGnutls code would try to do a handshake. Fix this, and test for it.
Attachment 230242 [details] pushed as 58fd3d5 - gnutls: Don't hang trying to handshake, if early close
It is still hanging for me with the following backtrace:
+ Trace 231259
Here is a test case: http://rishi.fedorapeople.org/gtls-cancel.tar.gz Hangs on every 2nd attempt on my system.
I can't duplicate this on my system unfortunately. I guess it's hard to reproduce because it involves a remote server. I did very that cancel_cb() is actually getting called. Dan, is soup_session_abort() supposed to try to flush data when closing?
oh, that was a separate bug, which got fixed as bug 688751. Sorry, I didn't notice that it had been mentioned here too