winlin

refine config, check the connections more precise

@@ -1489,23 +1489,21 @@ int SrsConfig::check_config() @@ -1489,23 +1489,21 @@ int SrsConfig::check_config()
1489 nb_consumed_fds += 3; 1489 nb_consumed_fds += 3;
1490 1490
1491 int nb_connections = get_max_connections(); 1491 int nb_connections = get_max_connections();
1492 - int nb_pipes = nb_connections * 2;  
1493 - int nb_reserved = 10; // reserved  
1494 - int nb_total = nb_connections + nb_pipes + nb_consumed_fds + nb_reserved; 1492 + int nb_total = nb_connections + nb_consumed_fds;
1495 1493
1496 int max_open_files = sysconf(_SC_OPEN_MAX); 1494 int max_open_files = sysconf(_SC_OPEN_MAX);
1497 - int nb_canbe = (max_open_files - (nb_consumed_fds + nb_reserved)) / 3 - 1; 1495 + int nb_canbe = max_open_files - nb_consumed_fds - 1;
1498 1496
1499 // for each play connections, we open a pipe(2fds) to convert SrsConsumver to io, 1497 // for each play connections, we open a pipe(2fds) to convert SrsConsumver to io,
1500 // refine performance, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 1498 // refine performance, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
1501 if (nb_total >= max_open_files) { 1499 if (nb_total >= max_open_files) {
1502 ret = ERROR_SYSTEM_CONFIG_INVALID; 1500 ret = ERROR_SYSTEM_CONFIG_INVALID;
1503 srs_error("invalid max_connections=%d, required=%d, system limit to %d, " 1501 srs_error("invalid max_connections=%d, required=%d, system limit to %d, "
1504 - "total=%d(max_connections=%d, nb_pipes=%d, nb_consumed_fds=%d, nb_reserved=%d), ret=%d. " 1502 + "total=%d(max_connections=%d, nb_consumed_fds=%d), ret=%d. "
1505 "you can change max_connections from %d to %d, or " 1503 "you can change max_connections from %d to %d, or "
1506 "you can login as root and set the limit: ulimit -HSn %d", 1504 "you can login as root and set the limit: ulimit -HSn %d",
1507 nb_connections, nb_total, max_open_files, 1505 nb_connections, nb_total, max_open_files,
1508 - nb_total, nb_connections, nb_pipes, nb_consumed_fds, nb_reserved, 1506 + nb_total, nb_connections, nb_consumed_fds,
1509 ret, nb_connections, nb_canbe, nb_total); 1507 ret, nb_connections, nb_canbe, nb_total);
1510 return ret; 1508 return ret;
1511 } 1509 }