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

This commit is contained in:
夏楚 2023-06-11 22:07:15 +08:00 committed by GitHub
parent fe37005526
commit 5ca4ed53b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 14 deletions

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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];

View File

@ -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();
}
}
}
}

View File

@ -21,7 +21,7 @@ using namespace std;
namespace mediakit {
MP4Demuxer::MP4Demuxer() {}
MP4Demuxer::MP4Demuxer() = default;
MP4Demuxer::~MP4Demuxer() {
closeMP4();

View File

@ -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();
}
}
}

View File

@ -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){

View File

@ -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();
}
}
}