mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-12 19:24:22 +08:00
修复MediaSource::close线程安全问题
主动或无人观看关闭流可能会由于线程安全问题导致崩溃
This commit is contained in:
@@ -42,19 +42,10 @@ WebRtcPusher::WebRtcPusher(const EventPoller::Ptr &poller,
|
||||
}
|
||||
|
||||
bool WebRtcPusher::close(MediaSource &sender) {
|
||||
// 此回调在其他线程触发 [AUTO-TRANSLATED:c98e7686]
|
||||
// This callback is triggered in another thread
|
||||
string err = StrPrinter << "close media: " << sender.getUrl();
|
||||
weak_ptr<WebRtcPusher> weak_self = static_pointer_cast<WebRtcPusher>(shared_from_this());
|
||||
getPoller()->async([weak_self, err]() {
|
||||
auto strong_self = weak_self.lock();
|
||||
if (strong_self) {
|
||||
strong_self->onShutdown(SockException(Err_shutdown, err));
|
||||
// 主动关闭推流,那么不延时注销 [AUTO-TRANSLATED:ee7cc580]
|
||||
// Actively close the stream, then do not delay the logout
|
||||
strong_self->_push_src = nullptr;
|
||||
}
|
||||
});
|
||||
onShutdown(SockException(Err_shutdown, "close media: " + sender.getUrl()));
|
||||
// 主动关闭推流,那么不延时注销 [AUTO-TRANSLATED:ee7cc580]
|
||||
// Actively close the stream, then do not delay the logout
|
||||
_push_src = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user