Commit 5ca4ed53 by 夏楚 Committed by GitHub

防止析构函数抛异常导致崩溃问题 (#2546)

parent fe370055
......@@ -124,7 +124,11 @@ MediaSource::MediaSource(const string &schema, const MediaTuple& tuple): _tuple(
}
MediaSource::~MediaSource() {
try {
unregist();
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
}
const string& MediaSource::getSchema() const {
......
......@@ -202,7 +202,11 @@ PlayerProxy::~PlayerProxy() {
_timer.reset();
// 避免析构时, 忘记回调api请求
if (_on_play) {
try {
_on_play(SockException(Err_shutdown, "player proxy close"));
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
_on_play = nullptr;
}
}
......
......@@ -31,8 +31,7 @@ MediaPusher::MediaPusher(const string &schema,
MediaPusher(MediaSource::find(schema, vhost, app, stream), poller){
}
MediaPusher::~MediaPusher() {
}
MediaPusher::~MediaPusher() = default;
static void setOnCreateSocket_l(const std::shared_ptr<PusherBase> &delegate, const Socket::onCreateSocket &cb){
auto helper = dynamic_pointer_cast<SocketHelper>(delegate);
......
......@@ -22,9 +22,7 @@ HlsMaker::HlsMaker(float seg_duration, uint32_t seg_number, bool seg_keep) {
_seg_keep = seg_keep;
}
HlsMaker::~HlsMaker() {
}
HlsMaker::~HlsMaker() = default;
void HlsMaker::makeIndexFile(bool eof) {
char file_content[1024];
......
......@@ -46,7 +46,11 @@ HlsCookieData::~HlsCookieData() {
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
uint64_t bytes = _bytes.load();
if (bytes >= iFlowThreshold * 1024) {
try {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, bytes, duration, true, static_cast<SockInfo &>(*_sock_info));
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
}
}
}
......
......@@ -21,7 +21,7 @@ using namespace std;
namespace mediakit {
MP4Demuxer::MP4Demuxer() {}
MP4Demuxer::MP4Demuxer() = default;
MP4Demuxer::~MP4Demuxer() {
closeMP4();
......
......@@ -66,7 +66,11 @@ RtpProcess::~RtpProcess() {
//流量统计事件广播
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
if (_total_bytes >= iFlowThreshold * 1024) {
try {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, false, static_cast<SockInfo &>(*this));
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
}
}
......
......@@ -28,7 +28,11 @@ RtpSender::RtpSender(EventPoller::Ptr poller) {
}
RtpSender::~RtpSender() {
try {
flush();
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
}
void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const function<void(uint16_t local_port, const SockException &ex)> &cb){
......
......@@ -16,9 +16,11 @@ SrtTransportImp::~SrtTransportImp() {
// 流量统计事件广播
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
if (_total_bytes >= iFlowThreshold * 1024) {
NoticeCenter::Instance().emitEvent(
Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, !_is_pusher,
static_cast<SockInfo &>(*this));
try {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, !_is_pusher, static_cast<SockInfo &>(*this));
} catch (std::exception &ex) {
WarnL << "Exception occurred: " << ex.what();
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论