mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
Increase open file limit on Linux
Add some assertions to VirtualMemory.cpp
This commit is contained in:
parent
3c70645f0b
commit
a46ef4f29a
2 changed files with 34 additions and 7 deletions
|
@ -12,6 +12,14 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
static int memfd_create(const char *name, unsigned int flags)
|
||||||
|
{
|
||||||
|
return syscall(__NR_memfd_create, name, flags);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace utils
|
namespace utils
|
||||||
{
|
{
|
||||||
// Convert memory protection (internal)
|
// Convert memory protection (internal)
|
||||||
|
@ -115,21 +123,27 @@ namespace utils
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, 0, m_size, NULL);
|
m_handle = ::CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_EXECUTE_READWRITE, 0, m_size, NULL);
|
||||||
|
verify(HERE), m_handle != INVALID_HANDLE_VALUE;
|
||||||
//#elif __linux__
|
//#elif __linux__
|
||||||
// m_file = ::memfd_create("mem1", 0);
|
// m_file = ::memfd_create("", 0);
|
||||||
// ::ftruncate(m_file, m_size);
|
// verify(HERE), m_file >= 0;
|
||||||
|
// verify(HERE), ::ftruncate(m_file, m_size) >= 0;
|
||||||
#else
|
#else
|
||||||
while ((m_file = ::shm_open("/rpcs3-mem1", O_RDWR | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) == -1)
|
while ((m_file = ::shm_open("/rpcs3-mem1", O_RDWR | O_CREAT | O_EXCL, S_IWUSR | S_IRUSR)) == -1)
|
||||||
{
|
{
|
||||||
if (errno != EEXIST)
|
if (m_file == -1 && errno == EMFILE)
|
||||||
return;
|
{
|
||||||
|
fmt::throw_exception("Too many open files. Raise the limit and try again.");
|
||||||
|
}
|
||||||
|
|
||||||
|
verify(HERE), errno == EEXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
::shm_unlink("/rpcs3-mem1");
|
verify(HERE), ::shm_unlink("/rpcs3-mem1") >= 0;
|
||||||
::ftruncate(m_file, m_size);
|
verify(HERE), ::ftruncate(m_file, m_size) >= 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_ptr = this->map(nullptr);
|
m_ptr = verify(HERE, this->map(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
shm::~shm()
|
shm::~shm()
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
@ -85,6 +90,14 @@ int main(int argc, char** argv)
|
||||||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
|
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
struct ::rlimit rlim;
|
||||||
|
rlim.rlim_cur = 4096;
|
||||||
|
rlim.rlim_max = 4096;
|
||||||
|
if (::setrlimit(RLIMIT_NOFILE, &rlim) != 0)
|
||||||
|
std::fprintf(stderr, "Failed to set max open file limit (4096).");
|
||||||
|
#endif
|
||||||
|
|
||||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue