Unverified 提交 00000045 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

Fix DtlsTransport timeout related things (#815)

Fixes #814
上级 ee7e9882
...@@ -988,17 +988,22 @@ namespace RTC ...@@ -988,17 +988,22 @@ namespace RTC
uv_timeval_t dtlsTimeout{ 0, 0 }; uv_timeval_t dtlsTimeout{ 0, 0 };
uint64_t timeoutMs; uint64_t timeoutMs;
// NOTE: If ret == 0 then ignore the value in dtlsTimeout.
// NOTE: No DTLSv_1_2_get_timeout() or DTLS_get_timeout() in OpenSSL 1.1.0-dev. // NOTE: No DTLSv_1_2_get_timeout() or DTLS_get_timeout() in OpenSSL 1.1.0-dev.
ret = DTLSv1_get_timeout(this->ssl, static_cast<void*>(&dtlsTimeout)); // NOLINT ret = DTLSv1_get_timeout(this->ssl, static_cast<void*>(&dtlsTimeout)); // NOLINT
if (ret == 0) if (ret == 0)
{
OnTimer(this->timer);
return true; return true;
}
timeoutMs = (dtlsTimeout.tv_sec * static_cast<uint64_t>(1000)) + (dtlsTimeout.tv_usec / 1000); timeoutMs = (dtlsTimeout.tv_sec * static_cast<uint64_t>(1000)) + (dtlsTimeout.tv_usec / 1000);
if (timeoutMs == 0) if (timeoutMs == 0)
{ {
OnTimer(this->timer);
return true; return true;
} }
else if (timeoutMs < 30000) else if (timeoutMs < 30000)
...@@ -1419,12 +1424,27 @@ namespace RTC ...@@ -1419,12 +1424,27 @@ namespace RTC
return; return;
} }
DTLSv1_handle_timeout(this->ssl); auto ret = DTLSv1_handle_timeout(this->ssl);
// If required, send DTLS data. // -1 means that too many timeouts had expired without progress or an
SendPendingOutgoingDtlsData(); // error occurs.
if (ret == -1)
{
MS_WARN_TAG(dtls, "DTLSv1_handle_timeout() failed");
Reset();
// Set the DTLS timer again. // Set state and notify the listener.
SetTimeout(); this->state = DtlsState::FAILED;
this->listener->OnDtlsTransportFailed(this);
}
else
{
// If required, send DTLS data.
SendPendingOutgoingDtlsData();
// Set the DTLS timer again.
SetTimeout();
}
} }
} // namespace RTC } // namespace RTC
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论