external/boringssl: Sync to 9bbdf5832de8a2d395303c669b594fc61c791f4d.

This includes the following changes:

https://boringssl.googlesource.com/boringssl/+log/c642aca28feb7e18f244658559f4042286aed0c8..9bbdf5832de8a2d395303c669b594fc61c791f4d

Test: BoringSSL CTS Presubmits.
Change-Id: Ieb6fcfee99c4cc496b2f6e1d3e6597784bd80189
diff --git a/src/ssl/d1_lib.cc b/src/ssl/d1_lib.cc
index 8ef1aa2..30110b4 100644
--- a/src/ssl/d1_lib.cc
+++ b/src/ssl/d1_lib.cc
@@ -150,22 +150,17 @@
   return 1;
 }
 
-void dtls1_double_timeout(SSL *ssl) {
+static void dtls1_double_timeout(SSL *ssl) {
   ssl->d1->timeout_duration_ms *= 2;
   if (ssl->d1->timeout_duration_ms > 60000) {
     ssl->d1->timeout_duration_ms = 60000;
   }
-  dtls1_start_timer(ssl);
 }
 
 void dtls1_stop_timer(SSL *ssl) {
-  /* Reset everything */
   ssl->d1->num_timeouts = 0;
   OPENSSL_memset(&ssl->d1->next_timeout, 0, sizeof(ssl->d1->next_timeout));
   ssl->d1->timeout_duration_ms = ssl->initial_timeout_duration_ms;
-
-  /* Clear retransmission buffer */
-  dtls_clear_outgoing_messages(ssl);
 }
 
 int dtls1_check_timeout_num(SSL *ssl) {
@@ -183,10 +178,10 @@
   if (ssl->d1->num_timeouts > DTLS1_MAX_TIMEOUTS) {
     /* fail the connection, enough alerts have been sent */
     OPENSSL_PUT_ERROR(SSL, SSL_R_READ_TIMEOUT_EXPIRED);
-    return -1;
+    return 0;
   }
 
-  return 0;
+  return 1;
 }
 
 }  // namespace bssl
@@ -202,7 +197,7 @@
     return 0;
   }
 
-  /* If no timeout is set, just return NULL */
+  /* If no timeout is set, just return 0. */
   if (ssl->d1->next_timeout.tv_sec == 0 && ssl->d1->next_timeout.tv_usec == 0) {
     return 0;
   }
@@ -210,7 +205,7 @@
   struct OPENSSL_timeval timenow;
   ssl_get_current_time(ssl, &timenow);
 
-  /* If timer already expired, set remaining time to 0 */
+  /* If timer already expired, set remaining time to 0. */
   if (ssl->d1->next_timeout.tv_sec < timenow.tv_sec ||
       (ssl->d1->next_timeout.tv_sec == timenow.tv_sec &&
        ssl->d1->next_timeout.tv_usec <= timenow.tv_usec)) {
@@ -218,7 +213,7 @@
     return 1;
   }
 
-  /* Calculate time left until timer expires */
+  /* Calculate time left until timer expires. */
   struct OPENSSL_timeval ret;
   OPENSSL_memcpy(&ret, &ssl->d1->next_timeout, sizeof(ret));
   ret.tv_sec -= timenow.tv_sec;
@@ -251,20 +246,20 @@
   ssl_reset_error_state(ssl);
 
   if (!SSL_is_dtls(ssl)) {
+    OPENSSL_PUT_ERROR(SSL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
     return -1;
   }
 
-  /* if no timer is expired, don't do anything */
+  /* If no timer is expired, don't do anything. */
   if (!dtls1_is_timer_expired(ssl)) {
     return 0;
   }
 
-  dtls1_double_timeout(ssl);
-
-  if (dtls1_check_timeout_num(ssl) < 0) {
+  if (!dtls1_check_timeout_num(ssl)) {
     return -1;
   }
 
+  dtls1_double_timeout(ssl);
   dtls1_start_timer(ssl);
   return dtls1_retransmit_outgoing_messages(ssl);
 }