Fix BIO_set_retry_special

Test this by using this helper in connect BIOs too and making sure that
didn't start breaking.

Change-Id: I2ea93446dd6490d9a026cd85c6058b3cbf663789
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/94809
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/bio/bio.cc b/crypto/bio/bio.cc
index 970c68f..a3be772 100644
--- a/crypto/bio/bio.cc
+++ b/crypto/bio/bio.cc
@@ -239,6 +239,10 @@
   FromOpaque(bio)->flags |= BIO_FLAGS_WRITE | BIO_FLAGS_SHOULD_RETRY;
 }
 
+void BIO_set_retry_special(BIO *bio) {
+  FromOpaque(bio)->flags |= BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY;
+}
+
 static const int kRetryFlags = BIO_FLAGS_RWS | BIO_FLAGS_SHOULD_RETRY;
 
 int BIO_get_retry_flags(BIO *bio) {
@@ -569,10 +573,6 @@
   return 1;
 }
 
-void BIO_set_retry_special(BIO *bio) {
-  FromOpaque(bio)->flags |= BIO_FLAGS_READ | BIO_FLAGS_IO_SPECIAL;
-}
-
 int BIO_set_write_buffer_size(BIO *bio, int buffer_size) { return 0; }
 
 static StaticMutex g_index_lock;
diff --git a/crypto/bio/connect.cc b/crypto/bio/connect.cc
index c5c74a5..7f4a17b 100644
--- a/crypto/bio/connect.cc
+++ b/crypto/bio/connect.cc
@@ -193,7 +193,7 @@
                       c->them_length);
         if (ret < 0) {
           if (bio_socket_should_retry(ret)) {
-            BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
+            BIO_set_retry_special(bio);
             c->state = BIO_CONN_S_BLOCKED_CONNECT;
             BIO_set_retry_reason(bio, BIO_RR_CONNECT);
           } else {
@@ -212,7 +212,7 @@
         i = bio_sock_error(FromOpaque(bio)->num);
         if (i) {
           if (bio_socket_should_retry(ret)) {
-            BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
+            BIO_set_retry_special(bio);
             c->state = BIO_CONN_S_BLOCKED_CONNECT;
             BIO_set_retry_reason(bio, BIO_RR_CONNECT);
             ret = -1;