mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #713, refine source to avoid critical fetch and create. 2.0.222
This commit is contained in:
parent
ec4d1b3b4f
commit
cb1d47bfef
5 changed files with 19 additions and 32 deletions
|
@ -731,17 +731,23 @@ ISrsSourceHandler::~ISrsSourceHandler()
|
|||
|
||||
std::map<std::string, SrsSource*> SrsSource::pool;
|
||||
|
||||
int SrsSource::create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps)
|
||||
int SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh, SrsSource** pps)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
SrsSource* source = NULL;
|
||||
if ((source = fetch(r)) != NULL) {
|
||||
*pps = source;
|
||||
return ret;
|
||||
}
|
||||
|
||||
string stream_url = r->get_stream_url();
|
||||
string vhost = r->vhost;
|
||||
|
||||
// should always not exists for create a source.
|
||||
srs_assert (pool.find(stream_url) == pool.end());
|
||||
|
||||
SrsSource* source = new SrsSource();
|
||||
source = new SrsSource();
|
||||
if ((ret = source->initialize(r, h, hh)) != ERROR_SUCCESS) {
|
||||
srs_freep(source);
|
||||
return ret;
|
||||
|
@ -774,20 +780,6 @@ SrsSource* SrsSource::fetch(SrsRequest* r)
|
|||
return source;
|
||||
}
|
||||
|
||||
SrsSource* SrsSource::fetch(std::string vhost, std::string app, std::string stream)
|
||||
{
|
||||
SrsSource* source = NULL;
|
||||
string stream_url = srs_generate_stream_url(vhost, app, stream);
|
||||
|
||||
if (pool.find(stream_url) == pool.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
source = pool[stream_url];
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
void SrsSource::dispose_all()
|
||||
{
|
||||
std::map<std::string, SrsSource*>::iterator it;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue