Change inspired by Rizlik review comments.

This commit is contained in:
Anthony Hu
2022-06-21 10:22:44 -04:00
parent 73435389ed
commit 1e84d1eb67

View File

@ -2188,18 +2188,38 @@ int MicriumReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
#ifdef WOLFSSL_DTLS
{
int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
if (ssl->options.handShakeDone)
/* Don't use ssl->options.handShakeDone since it is true even if
* we are in the process of renegotiation */
byte doDtlsTimeout = ssl->options.handShakeState != HANDSHAKE_DONE;
#ifdef WOLFSSL_DTLS13
if (ssl->options.dtls && IsAtLeastTLSv1_3(ssl->version)) {
if (
doDtlsTimeout =
doDtlsTimeout || ssl->dtls13Rtx.rtxRecords != NULL ||
(ssl->dtls13FastTimeout && ssl->dtls13Rtx.seenRecords != NULL);
}
#endif /* WOLFSSL_DTLS13 */
if (!doDtlsTimeout)
dtls_timeout = 0;
if (!wolfSSL_dtls_get_using_nonblock(ssl)) {
/* needs timeout in milliseconds */
#ifdef WOLFSSL_DTLS13
if (wolfSSL_dtls13_use_quick_timeout(ssl) &&
IsAtLeastTLSv1_3(ssl->version) && (dtls_timeout >= 4)) {
dtls_timeout = dtls_timeout / 4;
}
#endif /* WOLFSSL_DTLS13 */
NetSock_CfgTimeoutRxQ_Set(sd, dtls_timeout * 1000, &err);
if (err != NET_SOCK_ERR_NONE) {
WOLFSSL_MSG("NetSock_CfgTimeoutRxQ_Set failed");
}
}
}
#endif
#endif /* WOLFSSL_DTLS */
ret = NetSock_RxDataFrom(sd, buf, sz, ssl->rflags, &peer, &peerSz,
0, 0, 0, &err);