diff options
author | Steven Danneman <steven.danneman@isilon.com> | 2009-02-20 16:24:08 -0800 |
---|---|---|
committer | Steven Danneman <steven.danneman@isilon.com> | 2009-02-20 16:30:13 -0800 |
commit | 193be432a224918bf0fbecfb6705146476c15c07 (patch) | |
tree | b9b65d3603e82456c831eb89a81f7e9f6838bab9 /source3 | |
parent | 116ce19b10a1fd60776764974ad50776ff7c4714 (diff) | |
download | samba-193be432a224918bf0fbecfb6705146476c15c07.tar.gz samba-193be432a224918bf0fbecfb6705146476c15c07.tar.bz2 samba-193be432a224918bf0fbecfb6705146476c15c07.zip |
s3: Refactor of madvise() usage in c441f58d
* move to reinit_after_fork() to protect all Samba daemons
* only protect parent processes
Diffstat (limited to 'source3')
-rw-r--r-- | source3/lib/util.c | 7 | ||||
-rw-r--r-- | source3/smbd/server.c | 7 |
2 files changed, 7 insertions, 7 deletions
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")); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index e8ccba0873..28ce80b6c8 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -359,10 +359,6 @@ static void smbd_accept_connection(struct tevent_context *ev, /* Child code ... */ am_parent = 0; -#ifdef WITH_MADVISE_PROTECTED - madvise(NULL,0,MADV_PROTECT); -#endif - /* Stop zombies, the parent explicitly handles * them, counting worker smbds. */ CatchChild(); @@ -1135,9 +1131,6 @@ extern void build_options(bool screen); if (is_daemon && !interactive) { DEBUG( 3, ( "Becoming a daemon.\n" ) ); become_daemon(Fork, no_process_group); -#ifdef WITH_MADVISE_PROTECTED - madvise(NULL,0,MADV_PROTECT); -#endif } #if HAVE_SETPGID |