Fixed: Move setrlimit after initializing logs
This commit is contained in:
parent
bde61427a5
commit
f728a518a1
2 changed files with 44 additions and 25 deletions
|
@ -30,13 +30,6 @@
|
|||
#include <csignal>
|
||||
#endif
|
||||
|
||||
#ifdef NL_OS_MAC
|
||||
#include <stdio.h>
|
||||
#include <sys/resource.h>
|
||||
#include "nel/misc/dynloadlib.h"
|
||||
#include "app_bundle_utils.h"
|
||||
#endif
|
||||
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/command.h"
|
||||
#include "nel/net/tcp_sock.h"
|
||||
|
@ -226,23 +219,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
#endif // TEST_CRASH_COUNTER
|
||||
|
||||
#ifdef NL_OS_MAC
|
||||
struct rlimit rlp, rlp2, rlp3;
|
||||
|
||||
getrlimit(RLIMIT_NOFILE, &rlp);
|
||||
|
||||
rlp2.rlim_cur = 1024;
|
||||
rlp2.rlim_max = rlp.rlim_max;
|
||||
setrlimit(RLIMIT_NOFILE, &rlp2);
|
||||
|
||||
getrlimit(RLIMIT_NOFILE, &rlp3);
|
||||
nlinfo("rlimit before %d %d\n", rlp.rlim_cur, rlp.rlim_max);
|
||||
nlinfo("rlimit after %d %d\n", rlp3.rlim_cur, rlp3.rlim_max);
|
||||
|
||||
// add the bundle's plugins path as library search path (for nel drivers)
|
||||
CLibrary::addLibPath(getAppBundlePath() + "/Contents/PlugIns/nel/");
|
||||
#endif
|
||||
|
||||
#if defined(NL_OS_WINDOWS)
|
||||
|
||||
#ifdef TEST_CRASH_COUNTER
|
||||
|
@ -289,11 +265,11 @@ int main(int argc, char **argv)
|
|||
|
||||
#else
|
||||
// TODO for Linux : splashscreen
|
||||
#endif
|
||||
|
||||
// initialize log
|
||||
initLog();
|
||||
|
||||
#endif
|
||||
|
||||
// initialize patch manager and set the ryzom full path, before it's used
|
||||
CPatchManager *pPM = CPatchManager::getInstance();
|
||||
|
|
|
@ -105,6 +105,12 @@ extern HINSTANCE HInstance;
|
|||
extern HWND SlashScreen;
|
||||
#endif // NL_OS_WINDOWS
|
||||
|
||||
#ifdef NL_OS_MAC
|
||||
#include <stdio.h>
|
||||
#include <sys/resource.h>
|
||||
#include "nel/misc/dynloadlib.h"
|
||||
#endif
|
||||
|
||||
#include "app_bundle_utils.h"
|
||||
|
||||
#include <new>
|
||||
|
@ -816,6 +822,43 @@ void initLog()
|
|||
|
||||
// Display the client version.
|
||||
nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str());
|
||||
|
||||
#ifdef NL_OS_MAC
|
||||
struct rlimit rlp, rlp2, rlp3;
|
||||
|
||||
getrlimit(RLIMIT_NOFILE, &rlp);
|
||||
|
||||
rlim_t value = 1024;
|
||||
|
||||
rlp2.rlim_cur = std::min(value, rlp.rlim_max);
|
||||
rlp2.rlim_max = rlp.rlim_max;
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &rlp2))
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
{
|
||||
nlwarning("Unable to set rlimit with error: the specified limit is invalid");
|
||||
}
|
||||
else if (errno == EPERM)
|
||||
{
|
||||
nlwarning("Unable to set rlimit with error: the limit specified would have raised the maximum limit value and the caller is not the super-user");
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("Unable to set rlimit with error: unknown error");
|
||||
}
|
||||
}
|
||||
|
||||
getrlimit(RLIMIT_NOFILE, &rlp3);
|
||||
nlinfo("rlimit before %llu %llu", (uint64)rlp.rlim_cur, (uint64)rlp.rlim_max);
|
||||
nlinfo("rlimit after %llu %llu", (uint64)rlp3.rlim_cur, (uint64)rlp3.rlim_max);
|
||||
|
||||
// add the bundle's plugins path as library search path (for nel drivers)
|
||||
if (CFile::isExists(getAppBundlePath() + "/Contents/PlugIns/nel"))
|
||||
{
|
||||
CLibrary::addLibPath(getAppBundlePath() + "/Contents/PlugIns/nel/");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue