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

bugfix: SrsAsyncCallWorker::cycle to crash #2282

wants to merge 1 commit into from

Conversation

bluestn
Copy link
Contributor

@bluestn bluestn commented Apr 13, 2021

    dvr {
        # the filter for dvr to apply to.
        #       all, dvr all streams of all apps.
        #       <app>/<stream>, apply to specified stream of app.
        # for example, to dvr the following two streams:
        #       live/stream1 live/stream2
        # default: all
        dvr_apply       all;
    }

@winlinvip winlinvip force-pushed the 3.0release branch 29 times, most recently from ccd8c86 to b59c37e Compare August 15, 2021 09:10
@winlinvip winlinvip force-pushed the 3.0release branch 2 times, most recently from 1ca9308 to 8d44b98 Compare August 15, 2021 09:22
@winlinvip winlinvip self-requested a review August 27, 2021 00:09
@winlinvip winlinvip self-assigned this Aug 27, 2021
@winlinvip winlinvip modified the milestone: SRS 4.0 release Aug 27, 2021
@ossrs ossrs deleted a comment from srgt305 Aug 29, 2021
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

@winlinvip
Copy link
Member

winlinvip commented Sep 4, 2021

A more suitable solution:

  1. dvr_apply does not support reload, so we can support it through the HTTP API by recording different streams.
  2. Move SrsDvrPlan.async to the global scope to avoid each Plan having its own asynchronous worker, thus preventing frequent opening and closing of workers.

I mentioned a new issue: #2181.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Sep 4, 2021

Still need to thank @bluestn for the Pull Request.

TRANS_BY_GPT3

peipeiguo added a commit to peipeiguo/srs that referenced this pull request Sep 7, 2022
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants