mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-02 14:07:10 +02:00
[desktop] Increase rlimit on UNIX/Apple (#4030)
Sets max open fd limit to 8192 on non-windows platforms (or bounds it to the system hard limit). Complement to the previous VFS PR. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4030 Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
0473747f94
commit
b7fcec4985
1 changed files with 18 additions and 3 deletions
|
|
@ -15,6 +15,10 @@
|
||||||
#include "qt_common/gui_settings.h"
|
#include "qt_common/gui_settings.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -106,16 +110,27 @@ int main(int argc, char* argv[]) {
|
||||||
QCoreApplication::setOrganizationName(QStringLiteral("eden"));
|
QCoreApplication::setOrganizationName(QStringLiteral("eden"));
|
||||||
QCoreApplication::setApplicationName(QStringLiteral("eden"));
|
QCoreApplication::setApplicationName(QStringLiteral("eden"));
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
// Increases the maximum open file limit.
|
// Increases the maximum open file limit.
|
||||||
|
// TODO: This should be common to all frontends.
|
||||||
|
#ifdef _WIN32
|
||||||
// MSVCRT limits this to 2048 for some inexplicable (and likely arcane) reason,
|
// MSVCRT limits this to 2048 for some inexplicable (and likely arcane) reason,
|
||||||
// so we have to account for that as well.
|
// so we have to account for that as well.
|
||||||
#ifdef __MSVCRT__
|
#ifdef __MSVCRT__
|
||||||
_setmaxstdio(2048);
|
_setmaxstdio(2048);
|
||||||
#else
|
#else
|
||||||
_setmaxstdio(8192);
|
_setmaxstdio(8192);
|
||||||
#endif
|
#endif // __MSVCRT__
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__unix__) || defined(__APPLE__)
|
||||||
|
// Set the max open file limit to 8192, or the hard limit.
|
||||||
|
// Most sane systems should not hit the hard limit here.
|
||||||
|
struct rlimit rl;
|
||||||
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
|
||||||
|
rl.rlim_cur = std::min<rlim_t>(8192, rl.rlim_max);
|
||||||
|
setrlimit(RLIMIT_NOFILE, &rl);
|
||||||
|
}
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
// If you start a bundle (binary) on OSX without the Terminal, the working directory is "/".
|
// If you start a bundle (binary) on OSX without the Terminal, the working directory is "/".
|
||||||
// But since we require the working directory to be the executable path for the location of
|
// But since we require the working directory to be the executable path for the location of
|
||||||
// the user folder in the Qt Frontend, we need to cd into that working directory
|
// the user folder in the Qt Frontend, we need to cd into that working directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue