Remove usage of rtc::MessageHandler in OpenSSLAdapter
Bug: webrtc:11988 Change-Id: I4ced39190630139fe31d449ac23385885432931d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272181 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37824}
This commit is contained in:
parent
a535ee664c
commit
e7280c314d
@ -33,8 +33,8 @@
|
||||
#endif
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/units/time_delta.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/openssl.h"
|
||||
@ -166,6 +166,8 @@ static void LogSslError() {
|
||||
|
||||
namespace rtc {
|
||||
|
||||
using ::webrtc::TimeDelta;
|
||||
|
||||
namespace webrtc_openssl_adapter_internal {
|
||||
|
||||
// Simple O(n^2) implementation is sufficient for current use case.
|
||||
@ -392,7 +394,7 @@ int OpenSSLAdapter::ContinueSSL() {
|
||||
RTC_DCHECK(state_ == SSL_CONNECTING);
|
||||
|
||||
// Clear the DTLS timer
|
||||
Thread::Current()->Clear(this, MSG_TIMEOUT);
|
||||
timer_.reset();
|
||||
|
||||
int code = (role_ == SSL_CLIENT) ? SSL_connect(ssl_) : SSL_accept(ssl_);
|
||||
switch (SSL_get_error(ssl_, code)) {
|
||||
@ -420,10 +422,10 @@ int OpenSSLAdapter::ContinueSSL() {
|
||||
RTC_LOG(LS_VERBOSE) << " -- error want read";
|
||||
struct timeval timeout;
|
||||
if (DTLSv1_get_timeout(ssl_, &timeout)) {
|
||||
int delay = timeout.tv_sec * 1000 + timeout.tv_usec / 1000;
|
||||
|
||||
Thread::Current()->PostDelayed(RTC_FROM_HERE, delay, this, MSG_TIMEOUT,
|
||||
0);
|
||||
TimeDelta delay = TimeDelta::Seconds(timeout.tv_sec) +
|
||||
TimeDelta::Micros(timeout.tv_usec);
|
||||
Thread::Current()->PostDelayedTask(
|
||||
SafeTask(timer_.flag(), [this] { OnTimeout(); }), delay);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -470,7 +472,7 @@ void OpenSSLAdapter::Cleanup() {
|
||||
identity_.reset();
|
||||
|
||||
// Clear the DTLS timer
|
||||
Thread::Current()->Clear(this, MSG_TIMEOUT);
|
||||
timer_.reset();
|
||||
}
|
||||
|
||||
int OpenSSLAdapter::DoSslWrite(const void* pv, size_t cb, int* error) {
|
||||
@ -673,12 +675,10 @@ bool OpenSSLAdapter::IsResumedSession() {
|
||||
return (ssl_ && SSL_session_reused(ssl_) == 1);
|
||||
}
|
||||
|
||||
void OpenSSLAdapter::OnMessage(Message* msg) {
|
||||
if (MSG_TIMEOUT == msg->message_id) {
|
||||
RTC_LOG(LS_INFO) << "DTLS timeout expired";
|
||||
DTLSv1_handle_timeout(ssl_);
|
||||
ContinueSSL();
|
||||
}
|
||||
void OpenSSLAdapter::OnTimeout() {
|
||||
RTC_LOG(LS_INFO) << "DTLS timeout expired";
|
||||
DTLSv1_handle_timeout(ssl_);
|
||||
ContinueSSL();
|
||||
}
|
||||
|
||||
void OpenSSLAdapter::OnConnectEvent(Socket* socket) {
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/task_queue/pending_task_safety_flag.h"
|
||||
#include "rtc_base/buffer.h"
|
||||
#include "rtc_base/message_handler.h"
|
||||
#ifdef OPENSSL_IS_BORINGSSL
|
||||
#include "rtc_base/boringssl_identity.h"
|
||||
#else
|
||||
@ -45,8 +45,7 @@ std::string StrJoin(const std::vector<std::string>& list, char delimiter);
|
||||
|
||||
} // namespace webrtc_openssl_adapter_internal
|
||||
|
||||
class OpenSSLAdapter final : public SSLAdapter,
|
||||
public MessageHandlerAutoCleanup {
|
||||
class OpenSSLAdapter final : public SSLAdapter {
|
||||
public:
|
||||
static bool InitializeSSL();
|
||||
static bool CleanupSSL();
|
||||
@ -114,17 +113,15 @@ class OpenSSLAdapter final : public SSLAdapter,
|
||||
SSL_ERROR
|
||||
};
|
||||
|
||||
enum { MSG_TIMEOUT };
|
||||
|
||||
int BeginSSL();
|
||||
int ContinueSSL();
|
||||
void Error(absl::string_view context, int err, bool signal = true);
|
||||
void Cleanup();
|
||||
void OnTimeout();
|
||||
|
||||
// Return value and arguments have the same meanings as for Send; `error` is
|
||||
// an output parameter filled with the result of SSL_get_error.
|
||||
int DoSslWrite(const void* pv, size_t cb, int* error);
|
||||
void OnMessage(Message* msg) override;
|
||||
bool SSLPostConnectionCheck(SSL* ssl, absl::string_view host);
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
@ -185,6 +182,8 @@ class OpenSSLAdapter final : public SSLAdapter,
|
||||
std::vector<std::string> elliptic_curves_;
|
||||
// Holds the result of the call to run of the ssl_cert_verify_->Verify()
|
||||
bool custom_cert_verifier_status_;
|
||||
// Flag to cancel pending timeout task.
|
||||
webrtc::ScopedTaskSafety timer_;
|
||||
};
|
||||
|
||||
// The OpenSSLAdapterFactory is responsbile for creating multiple new
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user