mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-28 13:04:07 +08:00
fix: restore SRT transport cleanup on session error (#4777)
### Motivation - Restore the transport cleanup path on SRT session errors so `SrtTransport::onShutdown` runs its unregister logic and prevents unbounded growth of weak_ptr entries in the transport manager that could lead to a memory-exhaustion DoS. ### Description - Re-enabled shutdown cleanup in `srt/SrtSession.cpp` by capturing `err` in the delayed callback and calling `transport->onShutdown(err)` from the `getPoller()->async` lambda. ### Testing - Ran `cmake -S . -B build` to sanity-check configuration; configuration failed in this environment due to a missing `3rdpart/ZLToolKit` submodule and unrelated CMake errors, not due to the patch. ------ [Codex Task](https://chatgpt.com/codex/cloud/tasks/task_e_69b32b68f8ac8320b6a9b0fad53594c6) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -66,11 +66,18 @@ void SrtSession::onError(const SockException &err) {
|
||||
// 防止互相引用导致不释放 [AUTO-TRANSLATED:82547e46]
|
||||
// Prevent mutual reference from causing non-release
|
||||
auto transport = std::move(_transport);
|
||||
|
||||
// Only shut down the transport if this session is still the selected one;
|
||||
// otherwise a migrated session has already taken over and should not be affected.
|
||||
if (transport->getSession().get() != static_cast<Session *>(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPoller()->async(
|
||||
[transport] {
|
||||
[transport, err] {
|
||||
// 延时减引用,防止使用transport对象时,销毁对象 [AUTO-TRANSLATED:09dd6609]
|
||||
// Delayed dereference to prevent object destruction when using the transport object
|
||||
//transport->onShutdown(err);
|
||||
transport->onShutdown(err);
|
||||
},
|
||||
false);
|
||||
}
|
||||
@@ -83,4 +90,4 @@ void SrtSession::onManager() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace SRT
|
||||
} // namespace SRT
|
||||
|
||||
Reference in New Issue
Block a user