rust: bssl-tls: Reset retry flags before I/O transactions

Signed-off-by: Xiangfei Ding <xfding@google.com>
Change-Id: I14d7b60ae5af30e24897208dda702a406a6a6964
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/102747
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/rust/bssl-tls/src/io.rs b/rust/bssl-tls/src/io.rs
index ca5a9ea..176c78f 100644
--- a/rust/bssl-tls/src/io.rs
+++ b/rust/bssl-tls/src/io.rs
@@ -348,6 +348,10 @@
     buffer: *mut c_char,
     buf_len: c_int,
 ) -> c_int {
+    unsafe {
+        // Safety: `bio` is valid as witnessed by the C callback contract.
+        bssl_sys::BIO_clear_retry_flags(bio);
+    }
     let rust_bio = unsafe {
         // Safety: `bio` is still valid and so is the `RustBio` which we have exclusive access to.
         rust_bio_data_mut(bio)
@@ -408,6 +412,10 @@
     buffer: *const c_char,
     buf_len: c_int,
 ) -> c_int {
+    unsafe {
+        // Safety: `bio` is valid as witnessed by the C callback contract.
+        bssl_sys::BIO_clear_retry_flags(bio);
+    }
     let rust_bio = unsafe {
         // Safety: `bio` is still valid and so is the `RustBio` which we have exclusive access to.
         rust_bio_data_mut(bio)
@@ -463,6 +471,10 @@
 }
 
 unsafe fn rust_bio_flush(bio: *mut bssl_sys::BIO) -> c_long {
+    unsafe {
+        // Safety: `bio` is valid as witnessed by the caller contract.
+        bssl_sys::BIO_clear_retry_flags(bio);
+    }
     let rust_bio = unsafe {
         // Safety: `bio` is still valid
         rust_bio_data_mut(bio)