修复WebRtcSession对象可能泄露的bug (#4596)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled

This commit is contained in:
xia-chu 2025-12-17 21:42:25 +08:00
parent 2cbe4b714b
commit 1e6a8964cc
2 changed files with 4 additions and 3 deletions

@ -1 +1 @@
Subproject commit 493d14e1682cc0c79e72b3893dd98f865d45b8e9
Subproject commit b8c91595f5e49cc8d4603eac577aee92b5c7ec8e

View File

@ -69,10 +69,11 @@ void WebRtcSession::onRecv_l(const char *data, size_t len) {
auto sock = Socket::createSocket(transport->getPoller(), false);
// 1、克隆socket(fd不变)切换poller线程到WebRtcTransport所在线程 [AUTO-TRANSLATED:f930bfab]
// 1. Clone socket (fd remains unchanged), switch poller thread to the thread where WebRtcTransport is located
sock->cloneSocket(*(getSock()));
auto on_complete = sock->cloneSocket(*(getSock()));
auto server = _server;
std::string str(data, len);
sock->getPoller()->async([sock, server, str](){
// on_complete在创建WebRtcSession后才析构(才开始网络事件监听)
sock->getPoller()->async([sock, server, str, on_complete](){
auto strong_server = server.lock();
if (strong_server) {
auto session = static_pointer_cast<WebRtcSession>(strong_server->createSession(sock));