From 193be432a224918bf0fbecfb6705146476c15c07 Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Fri, 20 Feb 2009 16:24:08 -0800 Subject: s3: Refactor of madvise() usage in c441f58d * move to reinit_after_fork() to protect all Samba daemons * only protect parent processes --- source3/lib/util.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/util.c b/source3/lib/util.c index baac26b9aa..cda1fb474d 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -899,6 +899,13 @@ bool reinit_after_fork(struct messaging_context *msg_ctx, * numbers as each other */ set_need_random_reseed(); +#ifdef WITH_MADVISE_PROTECTED + /* Protect parent process from being killed by kernel when system + * memory is low. Child processes can still be killed */ + if(!parent_longlived) + madvise(NULL,0,MADV_PROTECT); +#endif + /* tdb needs special fork handling */ if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) { DEBUG(0,("tdb_reopen_all failed.\n")); -- cgit