mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Merge pull request #10853 from Chocobo1/limits
Adjust open file descriptor limit on startup
This commit is contained in:
commit
a305032c39
1 changed files with 24 additions and 0 deletions
|
@ -33,6 +33,9 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
#if !defined Q_OS_WIN && !defined Q_OS_HAIKU
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif defined Q_OS_WIN && defined DISABLE_GUI
|
#elif defined Q_OS_WIN && defined DISABLE_GUI
|
||||||
|
@ -116,9 +119,17 @@ void displayBadArgMessage(const QString &message);
|
||||||
void showSplashScreen();
|
void showSplashScreen();
|
||||||
#endif // DISABLE_GUI
|
#endif // DISABLE_GUI
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
void adjustFileDescriptorLimit();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Main
|
// Main
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
adjustFileDescriptorLimit();
|
||||||
|
#endif
|
||||||
|
|
||||||
// We must save it here because QApplication constructor may change it
|
// We must save it here because QApplication constructor may change it
|
||||||
bool isOneArg = (argc == 2);
|
bool isOneArg = (argc == 2);
|
||||||
|
|
||||||
|
@ -397,3 +408,16 @@ bool userAgreesWithLegalNotice()
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
void adjustFileDescriptorLimit()
|
||||||
|
{
|
||||||
|
rlimit limit {};
|
||||||
|
|
||||||
|
if (getrlimit(RLIMIT_NOFILE, &limit) != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
limit.rlim_cur = limit.rlim_max;
|
||||||
|
setrlimit(RLIMIT_NOFILE, &limit);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue