Bug 1859474 - Don't release TCPSocket on socket thread. r=#necko-reviewers a=pascalc

Since TCPSocket might be released on the socket thread, it might cause a
crash when TCPSocket is destroyed on this thread.

Since we use mozilla::SyncRunnable::DispatchToThread, this is synchronous
call. So it is unnecessary to touch reference count on this thread.

Differential Revision: https://phabricator.services.mozilla.com/D251990
This commit is contained in:
Makoto Kato
2025-06-04 12:19:16 +02:00
committed by pchevrel@mozilla.com
parent 724e2686ee
commit 28930a0a73

View File

@@ -470,8 +470,10 @@ void TCPSocket::ActivateTLS() {
return;
}
auto CallActivateTLS = [sock = RefPtr{this}]() mutable {
sock->ActivateTLSHelper();
// Since we use mozilla::SyncRunnable::DispatchToThread, it is unnecessary to
// AddRef/Release TCPSocket in CallActivateTLS.
auto CallActivateTLS = [&self = *this]() mutable {
self.ActivateTLSHelper();
};
mozilla::SyncRunnable::DispatchToThread(
socketThread,