mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the max connections, compare the system ulimit max open files, error when exeed limit
This commit is contained in:
parent
5f7ff37e64
commit
ebf9e560b1
24 changed files with 133 additions and 4 deletions
|
@ -23,6 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_config.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -1405,6 +1406,18 @@ int SrsConfig::check_config()
|
|||
return ret;
|
||||
}
|
||||
|
||||
// check max connections of system limits
|
||||
if (true) {
|
||||
int max_open_files = sysconf(_SC_OPEN_MAX);
|
||||
if (get_max_connections() > max_open_files) {
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("invalid max_connections=%d, system limit to %d, ret=%d. "
|
||||
"you can login as root and set the limit: ulimit -HSn %d", get_max_connections(), max_open_files,
|
||||
ret, get_max_connections());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// check heartbeat
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -197,7 +197,9 @@ void SrsFastLog::error(const char* tag, int context_id, const char* fmt, ...)
|
|||
va_end(ap);
|
||||
|
||||
// add strerror() to error msg.
|
||||
size += snprintf(log_data + size, LOG_MAX_SIZE - size, "(%s)", strerror(errno));
|
||||
if (errno != 0) {
|
||||
size += snprintf(log_data + size, LOG_MAX_SIZE - size, "(%s)", strerror(errno));
|
||||
}
|
||||
|
||||
write_log(fd, log_data, size, SrsLogLevel::Error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue