diff options
| author | Dan Engelbrecht <[email protected]> | 2022-04-12 19:20:51 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-04-12 19:20:51 +0200 |
| commit | f4ba5e54262ed2d67fdaee803a212bdafa1cf2aa (patch) | |
| tree | ba5c72255cfd8ce8317c2ec53403c2f863f7f404 /zencore/filesystem.cpp | |
| parent | set file limit on zenserver test (diff) | |
| download | zen-f4ba5e54262ed2d67fdaee803a212bdafa1cf2aa.tar.xz zen-f4ba5e54262ed2d67fdaee803a212bdafa1cf2aa.zip | |
cleanup
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index e2778089b..8e75ad773 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -986,6 +986,31 @@ GetRunningExecutablePath() #endif // ZEN_PLATFORM_WINDOWS } +void +InitializeOpenFileCount() +{ +#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC + struct rlimit Limit; + int Error = getrlimit(RLIMIT_NOFILE, &Limit); + if (Error) + { + ZEN_WARN("failed getting rlimit RLIMIT_NOFILE, reason '{}'", zen::MakeErrorCode(Error).message()); + } + else + { + struct rlimit NewLimit = Limit; + NewLimit.rlim_cur = NewLimit.rlim_max; + ZEN_INFO("changing RLIMIT_NOFILE from rlim_cur = {}, rlim_max {} to rlim_cur = {}, rlim_max {}", Limit.rlim_cur, Limit.rlim_max, NewLimit.rlim_cur, NewLimit.rlim_max); + + Error = setrlimit(RLIMIT_NOFILE, &NewLimit); + if (Error != 0) + { + ZEN_WARN("failed to set RLIMIT_NOFILE limits from rlim_cur = {}, rlim_max {} to rlim_cur = {}, rlim_max {}, reason '{}'", Limit.rlim_cur, Limit.rlim_max, NewLimit.rlim_cur, NewLimit.rlim_max, zen::MakeErrorCode(Error).message()); + } + } +#endif +} + ////////////////////////////////////////////////////////////////////////// // // Testing related code follows... |