From f728a518a144671e807e69bc23ec64fa91e2bdb5 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 18 Mar 2016 22:10:19 +0100 Subject: [PATCH] Fixed: Move setrlimit after initializing logs --- code/ryzom/client/src/client.cpp | 26 +------------------ code/ryzom/client/src/init.cpp | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/code/ryzom/client/src/client.cpp b/code/ryzom/client/src/client.cpp index 1e140d3cc..dcce43cc0 100644 --- a/code/ryzom/client/src/client.cpp +++ b/code/ryzom/client/src/client.cpp @@ -30,13 +30,6 @@ #include #endif -#ifdef NL_OS_MAC -#include -#include -#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(); diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 18c8ba022..a55a09db9 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -105,6 +105,12 @@ extern HINSTANCE HInstance; extern HWND SlashScreen; #endif // NL_OS_WINDOWS +#ifdef NL_OS_MAC +#include +#include +#include "nel/misc/dynloadlib.h" +#endif + #include "app_bundle_utils.h" #include @@ -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 } //---------------------------------------------------