Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: SrsAsyncCallWorker::cycle to crash #2282

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion trunk/src/app/srs_app_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req)
{
static bool DEFAULT = true;

if (!dvr_apply || dvr_apply->args.empty()) {
// if dvr_apply is null, return false to keep consistency with get_dvr_enabled() function
// if not, will occasionally cause SrsAsyncCallWorker::cycle to crash down with trd == 0x00
if ( !dvr_apply ){
return false;
}

if ( dvr_apply->args.empty()) {
Copy link
Member

@winlinvip winlinvip Aug 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the situation where trd is NULL in SrsAsyncCallWorker::cycle, and it only occurs when DvrPlan is being deleted.

SrsDvrPlan::~SrsDvrPlan()
{
    srs_freep(async);
}

SrsAsyncCallWorker::~SrsAsyncCallWorker()
{
    srs_freep(trd);
}

When DvrPlan stops, it will have a stop and clean task, which will cause a switch.

void SrsDvrPlan::on_unpublish()
{
    async->stop();
}

void SrsAsyncCallWorker::stop()
{
    flush_tasks();
    srs_cond_signal(wait);
    trd->stop();
}

In combination with the reload of dvr_apply, the above logic will be triggered frequently.

srs_error_t SrsDvr::on_reload_vhost_dvr_apply(string vhost)
{
    SrsConfDirective* conf = _srs_config->get_dvr_apply(req->vhost);
    bool v = srs_config_apply_filter(conf, req);
    
    on_unpublish();
    
    if ((err = on_publish()) != srs_success) {
        return srs_error_wrap(err, "on publish");
    }
}

So the problem should be in this place. To be determined specifically.

TRANS_BY_GPT3

return DEFAULT;
}

Expand Down