Clean up BIO_set_nbio() calls for DTLS
authorDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 14 May 2012 03:29:30 +0000 (22:29 -0500)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 14 May 2012 04:46:23 +0000 (23:46 -0500)
It's not necessary to do it twice for the same BIO, and it's not necessary
to get that BIO back from the SSL with SSL_get_[rw]bio() when we already
have it in a local variable.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
dtls.c

diff --git a/dtls.c b/dtls.c
index 611cce9..32f88f2 100644 (file)
--- a/dtls.c
+++ b/dtls.c
@@ -230,17 +230,15 @@ int connect_dtls_socket(struct openconnect_info *vpninfo)
        }
 
        /* Go Go Go! */
+       fcntl(dtls_fd, F_SETFL, fcntl(dtls_fd, F_GETFL) | O_NONBLOCK);
+
        dtls_bio = BIO_new_socket(dtls_fd, BIO_NOCLOSE);
+       /* Set non-blocking */
+       BIO_set_nbio(dtls_bio, 1);
        SSL_set_bio(dtls_ssl, dtls_bio, dtls_bio);
 
        SSL_set_options(dtls_ssl, SSL_OP_CISCO_ANYCONNECT);
 
-       /* Set non-blocking */
-       BIO_set_nbio(SSL_get_rbio(dtls_ssl), 1);
-       BIO_set_nbio(SSL_get_wbio(dtls_ssl), 1);
-
-       fcntl(dtls_fd, F_SETFL, fcntl(dtls_fd, F_GETFL) | O_NONBLOCK);
-
        vpninfo->new_dtls_fd = dtls_fd;
        vpninfo->new_dtls_ssl = dtls_ssl;