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:
@ -28,6 +28,7 @@
|
|||||||
#include "rtc_base/net_helpers.h"
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
|
#include "rtc_base/task_utils/to_queued_task.h"
|
||||||
#include "system_wrappers/include/field_trial.h"
|
#include "system_wrappers/include/field_trial.h"
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
@ -1288,11 +1289,11 @@ void TurnPort::ScheduleEntryDestruction(TurnEntry* entry) {
|
|||||||
RTC_DCHECK(!entry->destruction_timestamp().has_value());
|
RTC_DCHECK(!entry->destruction_timestamp().has_value());
|
||||||
int64_t timestamp = rtc::TimeMillis();
|
int64_t timestamp = rtc::TimeMillis();
|
||||||
entry->set_destruction_timestamp(timestamp);
|
entry->set_destruction_timestamp(timestamp);
|
||||||
invoker_.AsyncInvokeDelayed<void>(
|
thread()->PostDelayedTask(ToQueuedTask(task_safety_.flag(),
|
||||||
RTC_FROM_HERE, thread(),
|
|
||||||
[this, entry, timestamp] {
|
[this, entry, timestamp] {
|
||||||
DestroyEntryIfNotCancelled(entry, timestamp);
|
DestroyEntryIfNotCancelled(
|
||||||
},
|
entry, timestamp);
|
||||||
|
}),
|
||||||
TURN_PERMISSION_TIMEOUT);
|
TURN_PERMISSION_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
#include "absl/memory/memory.h"
|
#include "absl/memory/memory.h"
|
||||||
#include "p2p/base/port.h"
|
#include "p2p/base/port.h"
|
||||||
#include "p2p/client/basic_port_allocator.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_packet_socket.h"
|
||||||
#include "rtc_base/async_resolver_interface.h"
|
#include "rtc_base/async_resolver_interface.h"
|
||||||
#include "rtc_base/ssl_certificate.h"
|
#include "rtc_base/ssl_certificate.h"
|
||||||
|
#include "rtc_base/task_utils/pending_task_safety_flag.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class TurnCustomizer;
|
class TurnCustomizer;
|
||||||
@ -227,9 +227,6 @@ class TurnPort : public Port {
|
|||||||
|
|
||||||
rtc::AsyncPacketSocket* socket() const { return socket_; }
|
rtc::AsyncPacketSocket* socket() const { return socket_; }
|
||||||
|
|
||||||
// For testing only.
|
|
||||||
rtc::AsyncInvoker* invoker() { return &invoker_; }
|
|
||||||
|
|
||||||
// Signal with resolved server address.
|
// Signal with resolved server address.
|
||||||
// Parameters are port, server address and resolved server address.
|
// Parameters are port, server address and resolved server address.
|
||||||
// This signal will be sent only if server address is resolved successfully.
|
// 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.
|
// The number of retries made due to allocate mismatch error.
|
||||||
size_t allocate_mismatch_retries_;
|
size_t allocate_mismatch_retries_;
|
||||||
|
|
||||||
rtc::AsyncInvoker invoker_;
|
|
||||||
|
|
||||||
// Optional TurnCustomizer that can modify outgoing messages. Once set, this
|
// Optional TurnCustomizer that can modify outgoing messages. Once set, this
|
||||||
// must outlive the TurnPort's lifetime.
|
// must outlive the TurnPort's lifetime.
|
||||||
webrtc::TurnCustomizer* turn_customizer_ = nullptr;
|
webrtc::TurnCustomizer* turn_customizer_ = nullptr;
|
||||||
@ -429,6 +424,8 @@ class TurnPort : public Port {
|
|||||||
// to be more easy to work with.
|
// to be more easy to work with.
|
||||||
std::string turn_logging_id_;
|
std::string turn_logging_id_;
|
||||||
|
|
||||||
|
webrtc::ScopedTaskSafety task_safety_;
|
||||||
|
|
||||||
friend class TurnEntry;
|
friend class TurnEntry;
|
||||||
friend class TurnAllocateRequest;
|
friend class TurnAllocateRequest;
|
||||||
friend class TurnRefreshRequest;
|
friend class TurnRefreshRequest;
|
||||||
|
@ -634,6 +634,11 @@ class TurnPortTest : public ::testing::Test,
|
|||||||
Port::ORIGIN_MESSAGE);
|
Port::ORIGIN_MESSAGE);
|
||||||
Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
|
Connection* conn2 = turn_port_->CreateConnection(udp_port_->Candidates()[0],
|
||||||
Port::ORIGIN_MESSAGE);
|
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(conn2 != NULL);
|
||||||
ASSERT_TRUE_SIMULATED_WAIT(turn_create_permission_success_, kSimulatedRtt,
|
ASSERT_TRUE_SIMULATED_WAIT(turn_create_permission_success_, kSimulatedRtt,
|
||||||
fake_clock_);
|
fake_clock_);
|
||||||
@ -650,11 +655,11 @@ class TurnPortTest : public ::testing::Test,
|
|||||||
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
|
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
|
||||||
fake_clock_);
|
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
|
// Expect that it still processes an incoming ping and signals the
|
||||||
// unknown address.
|
// unknown address.
|
||||||
turn_unknown_address_ = false;
|
turn_unknown_address_ = false;
|
||||||
turn_port_->invoker()->Flush(rtc::Thread::Current());
|
fake_clock_.AdvanceTime(webrtc::TimeDelta::Seconds(5 * 60));
|
||||||
conn1->Ping(0);
|
conn1->Ping(0);
|
||||||
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
|
EXPECT_TRUE_SIMULATED_WAIT(turn_unknown_address_, kSimulatedRtt,
|
||||||
fake_clock_);
|
fake_clock_);
|
||||||
|
Reference in New Issue
Block a user