libressl / openbsd

Source code pulled from OpenBSD for LibreSSL - this includes most of the library and supporting code. The place to contribute to this code is via the OpenBSD CVS tree. Please mail patches to tech@openbsd.org, instead of submitting pull requests, since this tree is often rebased.
231 stars 92 forks source link

tls_close: nonblock-friendly bidirectional shutdown #26

Closed flrl closed 9 years ago

flrl commented 9 years ago

I noticed that tls_read, tls_write and tls_connect were non-blocking friendly, but tls_close was not yet

This implementation appears to be correct based on my reading of SSL_shutdown(3) (though I'm not familiar with OpenSSL's warts, so I don't know that it's not actually more complicated than this), specifically:

I guess one could wrap the SSL_shutdown calls in a loop instead, like do { ssl_ret = SSL_shutdown(...); } while (ssl_ret == 0); but I don't think that's correct. To my reading, SSL_shutdown will only return 0 once, and the next call will either complete the shutdown or fail.

4a6f656c commented 9 years ago

Committed, thanks.