Skip to content

Commit

Permalink
For #464, refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 16, 2018
1 parent ec362b2 commit 55c9619
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions trunk/src/app/srs_app_coworkers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ SrsCoWorkers::SrsCoWorkers()
SrsCoWorkers::~SrsCoWorkers()
{
map<string, SrsRequest*>::iterator it;
for (it = vhosts.begin(); it != vhosts.end(); ++it) {
for (it = streams.begin(); it != streams.end(); ++it) {
SrsRequest* r = it->second;
srs_freep(r);
}
vhosts.clear();
streams.clear();
}

SrsCoWorkers* SrsCoWorkers::instance()
Expand Down Expand Up @@ -90,8 +90,8 @@ SrsRequest* SrsCoWorkers::find_stream_info(string vhost, string app, string stre

// Get stream information from local cache.
string url = srs_generate_stream_url(conf->arg0(), app, stream);
map<string, SrsRequest*>::iterator it = vhosts.find(url);
if (it == vhosts.end()) {
map<string, SrsRequest*>::iterator it = streams.find(url);
if (it == streams.end()) {
return NULL;
}

Expand All @@ -105,13 +105,13 @@ srs_error_t SrsCoWorkers::on_publish(SrsSource* s, SrsRequest* r)
string url = r->get_stream_url();

// Delete the previous stream informations.
map<string, SrsRequest*>::iterator it = vhosts.find(url);
if (it != vhosts.end()) {
map<string, SrsRequest*>::iterator it = streams.find(url);
if (it != streams.end()) {
srs_freep(it->second);
}

// Always use the latest one.
vhosts[url] = r->copy();
streams[url] = r->copy();

return err;
}
Expand All @@ -120,10 +120,10 @@ void SrsCoWorkers::on_unpublish(SrsSource* s, SrsRequest* r)
{
string url = r->get_stream_url();

map<string, SrsRequest*>::iterator it = vhosts.find(url);
if (it != vhosts.end()) {
map<string, SrsRequest*>::iterator it = streams.find(url);
if (it != streams.end()) {
srs_freep(it->second);
vhosts.erase(it);
streams.erase(it);
}
}

2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_coworkers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SrsCoWorkers
private:
static SrsCoWorkers* _instance;
private:
std::map<std::string, SrsRequest*> vhosts;
std::map<std::string, SrsRequest*> streams;
private:
SrsCoWorkers();
virtual ~SrsCoWorkers();
Expand Down

0 comments on commit 55c9619

Please sign in to comment.