mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	refine config, check the connections more precise
This commit is contained in:
		
							parent
							
								
									de5e2d0a40
								
							
						
					
					
						commit
						efc85ed6df
					
				
					 1 changed files with 3431 additions and 3433 deletions
				
			
		
							
								
								
									
										10
									
								
								trunk/src/app/srs_app_config.cpp
									
										
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										10
									
								
								trunk/src/app/srs_app_config.cpp
									
										
									
									
									
										
										
										Executable file → Normal file
									
								
							| 
						 | 
				
			
			@ -1489,23 +1489,21 @@ int SrsConfig::check_config()
 | 
			
		|||
        nb_consumed_fds += 3;
 | 
			
		||||
        
 | 
			
		||||
        int nb_connections = get_max_connections();
 | 
			
		||||
        int nb_pipes = nb_connections * 2;
 | 
			
		||||
        int nb_reserved = 10; // reserved
 | 
			
		||||
        int nb_total = nb_connections + nb_pipes + nb_consumed_fds + nb_reserved;
 | 
			
		||||
        int nb_total = nb_connections + nb_consumed_fds;
 | 
			
		||||
        
 | 
			
		||||
        int max_open_files = sysconf(_SC_OPEN_MAX);
 | 
			
		||||
        int nb_canbe = (max_open_files - (nb_consumed_fds + nb_reserved)) / 3 - 1;
 | 
			
		||||
        int nb_canbe = max_open_files - nb_consumed_fds - 1;
 | 
			
		||||
 | 
			
		||||
        // for each play connections, we open a pipe(2fds) to convert SrsConsumver to io,
 | 
			
		||||
        // refine performance, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
 | 
			
		||||
        if (nb_total >= max_open_files) {
 | 
			
		||||
            ret = ERROR_SYSTEM_CONFIG_INVALID;
 | 
			
		||||
            srs_error("invalid max_connections=%d, required=%d, system limit to %d, "
 | 
			
		||||
                "total=%d(max_connections=%d, nb_pipes=%d, nb_consumed_fds=%d, nb_reserved=%d), ret=%d. "
 | 
			
		||||
                "total=%d(max_connections=%d, nb_consumed_fds=%d), ret=%d. "
 | 
			
		||||
                "you can change max_connections from %d to %d, or "
 | 
			
		||||
                "you can login as root and set the limit: ulimit -HSn %d", 
 | 
			
		||||
                nb_connections, nb_total, max_open_files, 
 | 
			
		||||
                nb_total, nb_connections, nb_pipes, nb_consumed_fds, nb_reserved,
 | 
			
		||||
                nb_total, nb_connections, nb_consumed_fds,
 | 
			
		||||
                ret, nb_connections, nb_canbe, nb_total);
 | 
			
		||||
            return ret;
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue