Delete AsyncInvoker usage in TurnServer
Bug: webrtc:12339 Change-Id: Ibcc5d9d5b5abf0d926290e3164f60dd46c0b460b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212666 Reviewed-by: Taylor <deadbeef@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33535}
This commit is contained in:
parent
a9ba450339
commit
2ba32f3423
@ -286,9 +286,13 @@ rtc_library("p2p_server_utils") {
|
||||
"../rtc_base:rtc_base_tests_utils",
|
||||
"../rtc_base:socket_address",
|
||||
"../rtc_base:threading",
|
||||
"../rtc_base/task_utils:to_queued_task",
|
||||
"../rtc_base/third_party/sigslot",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/algorithm:container" ]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("libstunprober") {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/packet_socket_factory.h"
|
||||
#include "api/transport/stun.h"
|
||||
#include "p2p/base/async_stun_tcp_socket.h"
|
||||
@ -25,6 +26,7 @@
|
||||
#include "rtc_base/message_digest.h"
|
||||
#include "rtc_base/socket_adapters.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "rtc_base/thread.h"
|
||||
|
||||
namespace cricket {
|
||||
@ -554,22 +556,16 @@ void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
|
||||
rtc::AsyncPacketSocket* socket = iter->first;
|
||||
socket->SignalReadPacket.disconnect(this);
|
||||
server_sockets_.erase(iter);
|
||||
std::unique_ptr<rtc::AsyncPacketSocket> socket_to_delete =
|
||||
absl::WrapUnique(socket);
|
||||
// We must destroy the socket async to avoid invalidating the sigslot
|
||||
// callback list iterator inside a sigslot callback. (In other words,
|
||||
// deleting an object from within a callback from that object).
|
||||
sockets_to_delete_.push_back(
|
||||
std::unique_ptr<rtc::AsyncPacketSocket>(socket));
|
||||
invoker_.AsyncInvoke<void>(RTC_FROM_HERE, rtc::Thread::Current(), [this] {
|
||||
RTC_DCHECK_RUN_ON(thread_);
|
||||
FreeSockets();
|
||||
});
|
||||
thread_->PostTask(webrtc::ToQueuedTask(
|
||||
[socket_to_delete = std::move(socket_to_delete)] {}));
|
||||
}
|
||||
}
|
||||
|
||||
void TurnServer::FreeSockets() {
|
||||
sockets_to_delete_.clear();
|
||||
}
|
||||
|
||||
TurnServerConnection::TurnServerConnection(const rtc::SocketAddress& src,
|
||||
ProtocolType proto,
|
||||
rtc::AsyncPacketSocket* socket)
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
|
||||
#include "api/sequence_checker.h"
|
||||
#include "p2p/base/port_interface.h"
|
||||
#include "rtc_base/async_invoker.h"
|
||||
#include "rtc_base/async_packet_socket.h"
|
||||
#include "rtc_base/socket_address.h"
|
||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||
@ -320,9 +319,6 @@ class TurnServer : public sigslot::has_slots<> {
|
||||
void DestroyInternalSocket(rtc::AsyncPacketSocket* socket)
|
||||
RTC_RUN_ON(thread_);
|
||||
|
||||
// Just clears |sockets_to_delete_|; called asynchronously.
|
||||
void FreeSockets() RTC_RUN_ON(thread_);
|
||||
|
||||
typedef std::map<rtc::AsyncPacketSocket*, ProtocolType> InternalSocketMap;
|
||||
typedef std::map<rtc::AsyncSocket*, ProtocolType> ServerSocketMap;
|
||||
|
||||
@ -341,17 +337,12 @@ class TurnServer : public sigslot::has_slots<> {
|
||||
|
||||
InternalSocketMap server_sockets_ RTC_GUARDED_BY(thread_);
|
||||
ServerSocketMap server_listen_sockets_ RTC_GUARDED_BY(thread_);
|
||||
// Used when we need to delete a socket asynchronously.
|
||||
std::vector<std::unique_ptr<rtc::AsyncPacketSocket>> sockets_to_delete_
|
||||
RTC_GUARDED_BY(thread_);
|
||||
std::unique_ptr<rtc::PacketSocketFactory> external_socket_factory_
|
||||
RTC_GUARDED_BY(thread_);
|
||||
rtc::SocketAddress external_addr_ RTC_GUARDED_BY(thread_);
|
||||
|
||||
AllocationMap allocations_ RTC_GUARDED_BY(thread_);
|
||||
|
||||
rtc::AsyncInvoker invoker_;
|
||||
|
||||
// For testing only. If this is non-zero, the next NONCE will be generated
|
||||
// from this value, and it will be reset to 0 after generating the NONCE.
|
||||
int64_t ts_for_next_nonce_ RTC_GUARDED_BY(thread_) = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user