mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	For #464, refine code
This commit is contained in:
		
							parent
							
								
									ec362b2774
								
							
						
					
					
						commit
						55c96192e2
					
				
					 2 changed files with 11 additions and 11 deletions
				
			
		|  | @ -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() | ||||
|  | @ -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; | ||||
|     } | ||||
|      | ||||
|  | @ -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; | ||||
| } | ||||
|  | @ -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); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue