Delete TurnPort usage of AsyncInvoker

Bug: webrtc:12339
Change-Id: I098b5f4b58c3ac0c275157c0c9d5a280b1cbef97
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212440
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Taylor <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33524}
This commit is contained in:
Niels Möller
2021-03-22 11:42:56 +01:00
committed by Commit Bot
parent eb282985e9
commit ffb7603b60
3 changed files with 17 additions and 14 deletions

View File

@ -28,6 +28,7 @@
#include "rtc_base/net_helpers.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/task_utils/to_queued_task.h"
#include "system_wrappers/include/field_trial.h"
namespace cricket {
@ -1288,12 +1289,12 @@ void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) {
RTC_DCHECK(!entry->destruction_timestamp().has_value());
int64_t timestamp = rtc::TimeMillis();
entry->set_destruction_timestamp(timestamp);
invoker_.AsyncInvokeDelayed<void>(
RTC_FROM_HERE, thread(),
[this, entry, timestamp] {
DestroyEntryIfNotCancelled(entry, timestamp);
},
TURN_PERMISSION_TIMEOUT);
thread()->PostDelayedTask(ToQueuedTask(task_safety_.flag(),
[this, entry, timestamp] {
DestroyEntryIfNotCancelled(
entry, timestamp);
}),
TURN_PERMISSION_TIMEOUT);
}
bool TurnPort::SetEntryChannelId(const rtc::SocketAddress& address,

View File

@ -23,10 +23,10 @@
#include "absl/memory/memory.h"
#include "p2p/base/port.h"
#include "p2p/client/basic_port_allocator.h"
#include "rtc_base/async_invoker.h"
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/async_resolver_interface.h"
#include "rtc_base/ssl_certificate.h"
#include "rtc_base/task_utils/pending_task_safety_flag.h"
namespace webrtc {
class TurnCustomizer;
@ -227,9 +227,6 @@ class TurnPort : public Port {
rtc::AsyncPacketSocket* socket() const { return socket_; }
// For testing only.
rtc::AsyncInvoker* invoker() { return &invoker_; }
// Signal with resolved server address.
// Parameters are port, server address and resolved server address.
// This signal will be sent only if server address is resolved successfully.
@ -415,8 +412,6 @@ class TurnPort : public Port {
// The number of retries made due to allocate mismatch error.
size_t allocate_mismatch_retries_;
rtc::AsyncInvoker invoker_;
// Optional TurnCustomizer that can modify outgoing messages. Once set, this
// must outlive the TurnPort's lifetime.
webrtc::TurnCustomizer* turn_customizer_ = nullptr;
@ -429,6 +424,8 @@ class TurnPort : public Port {
// to be more easy to work with.
std::string turn_logging_id_;
webrtc::ScopedTaskSafety task_safety_;
friend class TurnEntry;
friend class TurnAllocateRequest;
friend class TurnRefreshRequest;

View File

@ -634,6 +634,11 @@ class TurnPortTest : public ::testing::Test,
Port::ORIGIN_MESSAGE);
Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
Port::ORIGIN_MESSAGE);
// Increased to 10 minutes, to ensure that the TurnEntry times out before
// the TurnPort.
turn_port_->set_timeout_delay(10 * 60 * 1000);
ASSERT_TRUE(conn2 != NULL);
ASSERT_TRUE_SIMULATED_WAIT(turn_create_permission_success_, kSimulatedRtt,
fake_clock_);
@ -650,11 +655,11 @@ class TurnPortTest : public ::testing::Test,
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
fake_clock_);
// Flush all requests in the invoker to destroy the TurnEntry.
// Wait for TurnEntry to expire. Timeout is 5 minutes.
// Expect that it still processes an incoming ping and signals the
// unknown address.
turn_unknown_address_ = false;
turn_port_->invoker()->Flush(rtc::Thread::Current());
fake_clock_.AdvanceTime(webrtc::TimeDelta::Seconds(5 * 60));
conn1->Ping(0);
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
fake_clock_);