Skip to content

Commit

Permalink
Clean up BIO_set_nbio() calls for DTLS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed May 14, 2012
1 parent 4ba8fff commit 5dbf930
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dtls.c
Expand Up @@ -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;

Expand Down

0 comments on commit 5dbf930

Please sign in to comment.