mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	support reload atc
This commit is contained in:
		
							parent
							
								
									eda1ddc03d
								
							
						
					
					
						commit
						821b58af03
					
				
					 6 changed files with 40 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -554,7 +554,7 @@ int SrsConfig::reload()
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    // directly supported for reload:
 | 
			
		||||
    // chunk_size, ff_log_dir
 | 
			
		||||
    // chunk_size, ff_log_dir, max_connections
 | 
			
		||||
    
 | 
			
		||||
    // merge config: pithy_print
 | 
			
		||||
    if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) {
 | 
			
		||||
| 
						 | 
				
			
			@ -643,6 +643,17 @@ int SrsConfig::reload()
 | 
			
		|||
        // merge config: vhost modified.
 | 
			
		||||
        srs_trace("vhost %s modified, reload its detail.", vhost.c_str());
 | 
			
		||||
        if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) {
 | 
			
		||||
            // atc, only one per vhost
 | 
			
		||||
            if (!srs_directive_equals(new_vhost->get("atc"), old_vhost->get("atc"))) {
 | 
			
		||||
                for (it = subscribes.begin(); it != subscribes.end(); ++it) {
 | 
			
		||||
                    ISrsReloadHandler* subscribe = *it;
 | 
			
		||||
                    if ((ret = subscribe->on_reload_atc(vhost)) != ERROR_SUCCESS) {
 | 
			
		||||
                        srs_error("vhost %s notify subscribes atc failed. ret=%d", vhost.c_str(), ret);
 | 
			
		||||
                        return ret;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                srs_trace("vhost %s reload atc success.", vhost.c_str());
 | 
			
		||||
            }
 | 
			
		||||
            // gop_cache, only one per vhost
 | 
			
		||||
            if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) {
 | 
			
		||||
                for (it = subscribes.begin(); it != subscribes.end(); ++it) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,11 @@ int ISrsReloadHandler::on_reload_vhost_removed(string /*vhost*/)
 | 
			
		|||
    return ERROR_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ISrsReloadHandler::on_reload_atc(string /*vhost*/)
 | 
			
		||||
{
 | 
			
		||||
    return ERROR_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int ISrsReloadHandler::on_reload_gop_cache(string /*vhost*/)
 | 
			
		||||
{
 | 
			
		||||
    return ERROR_SUCCESS;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,6 +49,7 @@ public:
 | 
			
		|||
    virtual int on_reload_pithy_print();
 | 
			
		||||
    virtual int on_reload_vhost_added(std::string vhost);
 | 
			
		||||
    virtual int on_reload_vhost_removed(std::string vhost);
 | 
			
		||||
    virtual int on_reload_atc(std::string vhost);
 | 
			
		||||
    virtual int on_reload_gop_cache(std::string vhost);
 | 
			
		||||
    virtual int on_reload_queue_length(std::string vhost);
 | 
			
		||||
    virtual int on_reload_forward(std::string vhost);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -484,6 +484,25 @@ SrsSource::~SrsSource()
 | 
			
		|||
    srs_freep(req);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsSource::on_reload_atc(string vhost)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
    
 | 
			
		||||
    if (req->vhost != vhost) {
 | 
			
		||||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    // atc changed.
 | 
			
		||||
    bool enabled_atc = _srs_config->get_atc(vhost);
 | 
			
		||||
    
 | 
			
		||||
    srs_warn("vhost %s atc changed to %d, connected client may corrupt.", 
 | 
			
		||||
        vhost.c_str(), enabled_atc);
 | 
			
		||||
    
 | 
			
		||||
    gop_cache->clear();
 | 
			
		||||
    
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int SrsSource::on_reload_gop_cache(string vhost)
 | 
			
		||||
{
 | 
			
		||||
    int ret = ERROR_SUCCESS;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -266,6 +266,7 @@ public:
 | 
			
		|||
    virtual ~SrsSource();
 | 
			
		||||
// interface ISrsReloadHandler
 | 
			
		||||
public:
 | 
			
		||||
    virtual int on_reload_atc(std::string vhost);
 | 
			
		||||
    virtual int on_reload_gop_cache(std::string vhost);
 | 
			
		||||
    virtual int on_reload_queue_length(std::string vhost);
 | 
			
		||||
    virtual int on_reload_forward(std::string vhost);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue