Add BIO_do_connect.

Some consumers of connect BIOs connect them explicitly, and we already have the
BIO_ctrl hooked up.

Change-Id: Ie6b14f8ceb272b560e2b534e0b6c32fae050475b
Reviewed-on: https://boringssl-review.googlesource.com/7217
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/bio/connect.c b/crypto/bio/connect.c
index 0b0bf13..c63243d 100644
--- a/crypto/bio/connect.c
+++ b/crypto/bio/connect.c
@@ -542,3 +542,7 @@
 int BIO_set_nbio(BIO *bio, int on) {
   return BIO_ctrl(bio, BIO_C_SET_NBIO, on, NULL);
 }
+
+int BIO_do_connect(BIO *bio) {
+  return BIO_ctrl(bio, BIO_C_DO_STATE_MACHINE, 0, NULL);
+}
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index 38b896f..a2f0d83 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -561,6 +561,10 @@
  * returns one on success and zero otherwise. */
 OPENSSL_EXPORT int BIO_set_nbio(BIO *bio, int on);
 
+/* BIO_do_connect connects |bio| if it has not been connected yet. It returns
+ * one on success and <= 0 otherwise. */
+OPENSSL_EXPORT int BIO_do_connect(BIO *bio);
+
 
 /* Datagram BIOs.
  *