From 98ef2e18d4c605ecbc9a574f639aefb26ce9020c Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Thu, 3 May 2012 15:21:19 +0200 Subject: [PATCH] Forbid any swapping of routing deamon on Linux --- routed.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/routed.cpp b/routed.cpp index 3c3fd4ffa..7a5bad8c4 100644 --- a/routed.cpp +++ b/routed.cpp @@ -17,7 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ - +#ifdef __linux__ +#include +#endif #include #include @@ -62,7 +64,12 @@ BOOL WINAPI console_ctrl_handler(DWORD ctrl_type) #endif int main (int argc, char *argv[]) { +#ifdef __linux__ + if(!mlockall(MCL_CURRENT | MCL_FUTURE)) + ERR("Process " << argv[0] << "could not be locked to RAM"); +#endif #ifndef _WIN32 + installCrashHandler(argv[0]); #endif @@ -131,5 +138,9 @@ int main (int argc, char *argv[]) { } catch (std::exception& e) { std::cerr << "[fatal error] exception: " << e.what() << std::endl; } +#ifdef __linux__ + munlockall(); +#endif + return 0; }