mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Revert "Revert "for bug #194, refine the config""
This reverts commit b4c1d55311
.
This commit is contained in:
parent
b4c1d55311
commit
de5e2d0a40
1 changed files with 3433 additions and 3407 deletions
34
trunk/src/app/srs_app_config.cpp
Normal file → Executable file
34
trunk/src/app/srs_app_config.cpp
Normal file → Executable file
|
@ -1475,12 +1475,38 @@ int SrsConfig::check_config()
|
||||||
|
|
||||||
// check max connections of system limits
|
// check max connections of system limits
|
||||||
if (true) {
|
if (true) {
|
||||||
|
int nb_consumed_fds = (int)get_listen().size();
|
||||||
|
if (get_http_api_listen() > 0) {
|
||||||
|
nb_consumed_fds++;
|
||||||
|
}
|
||||||
|
if (get_http_stream_listen() > 0) {
|
||||||
|
nb_consumed_fds++;
|
||||||
|
}
|
||||||
|
if (get_log_tank_file()) {
|
||||||
|
nb_consumed_fds++;
|
||||||
|
}
|
||||||
|
// 0, 1, 2 for stdin, stdout and stderr.
|
||||||
|
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 max_open_files = sysconf(_SC_OPEN_MAX);
|
int max_open_files = sysconf(_SC_OPEN_MAX);
|
||||||
if (get_max_connections() > max_open_files) {
|
int nb_canbe = (max_open_files - (nb_consumed_fds + nb_reserved)) / 3 - 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;
|
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||||
srs_error("invalid max_connections=%d, system limit to %d, ret=%d. "
|
srs_error("invalid max_connections=%d, required=%d, system limit to %d, "
|
||||||
"you can login as root and set the limit: ulimit -HSn %d", get_max_connections(), max_open_files,
|
"total=%d(max_connections=%d, nb_pipes=%d, nb_consumed_fds=%d, nb_reserved=%d), ret=%d. "
|
||||||
ret, get_max_connections());
|
"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,
|
||||||
|
ret, nb_connections, nb_canbe, nb_total);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue