From 4d76a13b33db217e53c4868977867060623ca984 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Sat, 12 Sep 2020 15:41:52 +0200 Subject: [PATCH] Make StunRequest not use auto cleanup. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The class already clears the thread that's used in its dtor and consistently uses the same thread. Bug: webrtc:11908 Change-Id: I5ea8d00c2e59bf46c5b369be5b23cf1d8e1875c4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184060 Reviewed-by: Henrik Boström Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#32097} --- p2p/base/connection.h | 2 +- p2p/base/stun_request.cc | 10 ++++++++-- p2p/base/stun_request.h | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/p2p/base/connection.h b/p2p/base/connection.h index 7c468bcff8..88e930c216 100644 --- a/p2p/base/connection.h +++ b/p2p/base/connection.h @@ -65,7 +65,7 @@ class ConnectionRequest : public StunRequest { int resend_delay() override; private: - Connection* connection_; + Connection* const connection_; }; // Represents a communication link between a port on the local client and a diff --git a/p2p/base/stun_request.cc b/p2p/base/stun_request.cc index 44376ced95..d6210fc2dc 100644 --- a/p2p/base/stun_request.cc +++ b/p2p/base/stun_request.cc @@ -174,7 +174,8 @@ bool StunRequestManager::CheckResponse(const char* data, size_t size) { } StunRequest::StunRequest() - : count_(0), + : rtc::MessageHandler(false), + count_(0), timeout_(false), manager_(0), msg_(new StunMessage()), @@ -183,7 +184,12 @@ StunRequest::StunRequest() } StunRequest::StunRequest(StunMessage* request) - : count_(0), timeout_(false), manager_(0), msg_(request), tstamp_(0) { + : rtc::MessageHandler(false), + count_(0), + timeout_(false), + manager_(0), + msg_(request), + tstamp_(0) { msg_->SetTransactionID(rtc::CreateRandomString(kStunTransactionIdLength)); } diff --git a/p2p/base/stun_request.h b/p2p/base/stun_request.h index 1756904615..39f928eaf4 100644 --- a/p2p/base/stun_request.h +++ b/p2p/base/stun_request.h @@ -76,7 +76,7 @@ class StunRequestManager { private: typedef std::map RequestMap; - rtc::Thread* thread_; + rtc::Thread* const thread_; RequestMap requests_; std::string origin_; @@ -85,7 +85,7 @@ class StunRequestManager { // Represents an individual request to be sent. The STUN message can either be // constructed beforehand or built on demand. -class StunRequest : public rtc::MessageHandlerAutoCleanup { +class StunRequest : public rtc::MessageHandler { public: StunRequest(); explicit StunRequest(StunMessage* request);