[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Oct 19 07:28:02 UTC 2017


The branch, master has been updated
       via  5dc773a python: use communicate to fix Popen deadlock
       via  8ed3cac python: add a failed test to show Popen deadlock
       via  ea0cd97 source4/smbd: replace DEBUG( with DBG_
       via  1d03028 selftest: set ad_dc process model to prefork
       via  123042c source4/smbd: add a prefork process model.
       via  778e9a8 source4/smbd: Fix code formatting after refactoring.
       via  e027871 process_standard: Do not log at level 2 every time a child exits
       via  0840252 source4/smbd: Do not overstamp the process model with "single"
       via  62d7bf9 process_standard: Honour proc_ctx->inhibit_fork_on_accept
       via  193afc5 process_standard: Move child pipe setup further down standard_accept_connection()
       via  17d3a9d process_standard: Use the new process_context
       via  b852ad0  source4/smbd: refactor the process model for prefork
       via  6d7a8d8 tests: Add a blackbox test for smbcontrol
      from  f7cdd39 rpc_client: Fix wording in a DEBUG statement

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5dc773a5b00834c7a53130a73a48f49048bd55e8
Author: Joe Guo <joeg at catalyst.net.nz>
Date:   Fri Sep 15 16:13:26 2017 +1200

    python: use communicate to fix Popen deadlock
    
    `Popen.wait()` will deadlock when using stdout=PIPE and/or stderr=PIPE and the
    child process generates large output to a pipe such that it blocks waiting for
    the OS pipe buffer to accept more data. Use communicate() to avoid that.
    
    Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Oct 19 09:27:16 CEST 2017 on sn-devel-144

commit 8ed3cac9e558c60ab0b7e32133cea5e156ef9549
Author: Joe Guo <joeg at catalyst.net.nz>
Date:   Fri Sep 15 15:31:34 2017 +1200

    python: add a failed test to show Popen deadlock
    
    `Popen.wait()` will deadlock when using stdout=PIPE and/or stderr=PIPE and the
    child process generates large output to a pipe such that it blocks waiting for
    the OS pipe buffer to accept more data. Use communicate() to avoid that.
    
    This patch is commited to show the issue, a fix patch will come later.
    
    Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
    Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit ea0cd977a3d1966f00861dc01728fe8b95b43f59
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Sep 11 11:39:39 2017 +1200

    source4/smbd: replace DEBUG( with DBG_
    
    Update the debug logging to use the currently preferred debug macros
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 1d0302871a2ab253128ecfff4a3a6e0b1233472b
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Sep 5 12:31:52 2017 +1200

    selftest: set ad_dc process model to prefork
    
    Set the process model for ad_dc to prefork, so that the pre-fork gets
    exercised during self test.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 123042c2e3358dc6671ce0969aee7b0f0695590e
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Sep 7 14:30:15 2017 +1200

    source4/smbd: add a prefork process model.
    
    Add a pre fork process model to bound the number processes forked by
    samba.  Currently workers are only pre-forked for the ldap server,  all
    the other services have pre-fork support disabled.
    
    When pre-fork support is disabled a new process is started for each
    service, and requests are processed by that process.
    
    This commit partially reverts commit
    b5be45c453bd51373bade26c29828b500ba586ec.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 778e9a810ef48262efe250bebce3e88546acc694
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Sep 15 09:15:35 2017 +1200

    source4/smbd: Fix code formatting after refactoring.
    
    Fix code formatting from the refactoring in the previous commits.
    Done as a separate patch to make the changes to functionality easier
    to review.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit e027871b0d96b59d2ec60d5d21e4490f1e2d73cd
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Sep 18 13:02:13 2017 +1200

    process_standard: Do not log at level 2 every time a child exits
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 08402526704c6d586febadf401959bc3d8661836
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Sep 18 13:05:24 2017 +1200

    source4/smbd: Do not overstamp the process model with "single"
    
    Instead, except in RPC which is a special SNOWFLAKE, we rely on the struct
    service_details in the init function.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 62d7bf9e0ae94baaaa090051bd6b7cb40e5ef3c3
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Oct 19 15:15:33 2017 +1300

    process_standard: Honour proc_ctx->inhibit_fork_on_accept
    
    This allows the service to control if it should fork per accept() without needing
    to replace the whole process model with process_single.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 193afc55e6e467fa362ad93ea09ba0a92b6074a5
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Thu Oct 19 15:14:16 2017 +1300

    process_standard: Move child pipe setup further down standard_accept_connection()
    
    This avoids cleaning up on error from accept() but more importantly
    allows a future mode that acts like process_single and so has no child.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 17d3a9d431c2babb730b7e35c076ee714ca6a9df
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Mon Sep 18 12:56:09 2017 +1200

    process_standard: Use the new process_context
    
    Use the new process_context to control the from_parent_fd
    This avoids the use of global variables, and will in the next patch
    allow process_standard to run as what was known as single without
    over-stamping a different process model.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit b852ad044b98c0c574c3420956e153055d46136d
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Fri Sep 15 07:09:23 2017 +1200

     source4/smbd: refactor the process model for prefork
    
        Refactor the process model code to allow the addition of a prefork
        process model.
    
        - Add a process context to contain process model specific state
        - Add a service details structure to allow service to indicate which
          process model options they can support.
    
        In the new code the services advertise the features they support to the
        process model.  The process model context is plumbed through to allow the
        process model to keep track of the supported options, and any state
        the process model may require.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

commit 6d7a8d80cdc9ee996ff503d8834037001cf233d9
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Wed Sep 13 11:21:02 2017 +1200

    tests: Add a blackbox test for smbcontrol
    
    Add tests to check that samba processes have started and that they can be
    pinged.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    Reviewed-by: Garming Sam <garming at catalyst.net.nz>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/smbdotconf/base/preforkchildren.xml |  24 ++
 file_server/file_server.c                    |   6 +-
 lib/param/loadparm.c                         |   2 +
 python/samba/tests/__init__.py               |  14 +-
 python/samba/tests/blackbox/check_output.py  | 105 +++++++
 python/samba/tests/blackbox/smbcontrol.py    |  50 ++++
 selftest/target/Samba4.pm                    |   4 +-
 selftest/tests.py                            |   1 +
 source3/param/loadparm.c                     |   1 +
 source4/cldap_server/cldap_server.c          |   7 +-
 source4/dns_server/dns_server.c              |  24 +-
 source4/dsdb/dns/dns_update.c                |   7 +-
 source4/dsdb/kcc/kcc_service.c               |   6 +-
 source4/dsdb/repl/drepl_service.c            |   7 +-
 source4/echo_server/echo_server.c            |  33 +--
 source4/kdc/kdc-heimdal.c                    |  36 ++-
 source4/kdc/kdc-server.c                     |   3 +-
 source4/kdc/kdc-service-mit.c                |  24 +-
 source4/ldap_server/ldap_server.c            |  41 +--
 source4/nbt_server/nbt_server.c              |   6 +-
 source4/ntp_signd/ntp_signd.c                |  23 +-
 source4/rpc_server/dcerpc_server.c           |  56 ++--
 source4/rpc_server/dcerpc_server.h           |   3 +-
 source4/rpc_server/service_rpc.c             |  15 +-
 source4/scripting/bin/gen_output.py          |  53 ++++
 source4/scripting/bin/wscript_build          |   2 +-
 source4/selftest/tests.py                    |   7 +
 source4/smb_server/service_smb.c             |  18 +-
 source4/smb_server/smb_server.c              |   5 +-
 source4/smb_server/smb_server.h              |   3 +-
 source4/smbd/process_model.c                 |   7 +-
 source4/smbd/process_model.h                 |  15 +-
 source4/smbd/process_prefork.c               | 391 +++++++++++++++++++++++++++
 source4/smbd/process_single.c                |  26 +-
 source4/smbd/process_standard.c              | 163 +++++++----
 source4/smbd/server.c                        |  30 +-
 source4/smbd/service.c                       |  20 +-
 source4/smbd/service.h                       |  18 ++
 source4/smbd/service_named_pipe.c            |  31 ++-
 source4/smbd/service_stream.c                |  72 +++--
 source4/smbd/service_stream.h                |   1 +
 source4/smbd/service_task.c                  |  26 +-
 source4/smbd/service_task.h                  |   1 +
 source4/smbd/wscript_build                   |   7 +
 source4/torture/rpc/spoolss_notify.c         |   7 +-
 source4/web_server/web_server.c              |  28 +-
 source4/winbind/winbindd.c                   |  11 +-
 source4/wrepl_server/wrepl_in_connection.c   |  52 ++--
 source4/wrepl_server/wrepl_out_helpers.c     |   4 +-
 source4/wrepl_server/wrepl_server.c          |   7 +-
 50 files changed, 1178 insertions(+), 325 deletions(-)
 create mode 100644 docs-xml/smbdotconf/base/preforkchildren.xml
 create mode 100644 python/samba/tests/blackbox/check_output.py
 create mode 100644 python/samba/tests/blackbox/smbcontrol.py
 create mode 100755 source4/scripting/bin/gen_output.py
 create mode 100644 source4/smbd/process_prefork.c


Changeset truncated at 500 lines:

diff --git a/docs-xml/smbdotconf/base/preforkchildren.xml b/docs-xml/smbdotconf/base/preforkchildren.xml
new file mode 100644
index 0000000..720e439
--- /dev/null
+++ b/docs-xml/smbdotconf/base/preforkchildren.xml
@@ -0,0 +1,24 @@
+<samba:parameter name="prefork children"
+                 context="G"
+                 type="integer"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+	<para>This option controls the number of worker processes that are
+		started for each service when prefork process model is enabled.
+		The prefork children are only started for those services that
+		support prefork (currently only ldap). For processes that don't
+		support preforking all requests are handled by a single process
+		for that service.
+	</para>
+
+	<para>This should be set to a small multiple of the number of CPU's
+		available on the server</para>
+
+	<para>Additionally the number of prefork children can be specified for
+		an individual service by using "prefork children: service name"
+		i.e. "prefork children:ldap = 8" to set the number of ldap
+		worker processes.</para>
+</description>
+
+<value type="default">1</value>
+</samba:parameter>
diff --git a/file_server/file_server.c b/file_server/file_server.c
index 83641f8..20fa577 100644
--- a/file_server/file_server.c
+++ b/file_server/file_server.c
@@ -97,5 +97,9 @@ NTSTATUS server_service_s3fs_init(TALLOC_CTX *);
 
 NTSTATUS server_service_s3fs_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "s3fs", s3fs_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true
+	};
+	return register_server_service(ctx, "s3fs", s3fs_task_init, &details);
 }
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index a74a873..a1adb99 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -2993,6 +2993,8 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 				  "rpc server dynamic port range",
 				  "49152-65535");
 
+	lpcfg_do_global_parameter(lp_ctx, "prefork children", "1");
+
 	for (i = 0; parm_table[i].label; i++) {
 		if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
 			lp_ctx->flags[i] |= FLAG_DEFAULT;
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py
index d012113..d634aca 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -326,20 +326,22 @@ class BlackboxTestCase(TestCaseInTempDir):
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE,
                              shell=True)
-        retcode = p.wait()
+        stdoutdata, stderrdata = p.communicate()
+        retcode = p.returncode
         if retcode != expected:
             raise BlackboxProcessError(retcode,
                                        line,
-                                       p.stdout.read(),
-                                       p.stderr.read())
+                                       stdoutdata,
+                                       stderrdata)
 
     def check_output(self, line):
         line = self._make_cmdline(line)
         p = subprocess.Popen(line, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, close_fds=True)
-        retcode = p.wait()
+        stdoutdata, stderrdata = p.communicate()
+        retcode = p.returncode
         if retcode:
-            raise BlackboxProcessError(retcode, line, p.stdout.read(), p.stderr.read())
-        return p.stdout.read()
+            raise BlackboxProcessError(retcode, line, stdoutdata, stderrdata)
+        return stdoutdata
 
 
 def connect_samdb(samdb_url, lp=None, session_info=None, credentials=None,
diff --git a/python/samba/tests/blackbox/check_output.py b/python/samba/tests/blackbox/check_output.py
new file mode 100644
index 0000000..d7e41a8
--- /dev/null
+++ b/python/samba/tests/blackbox/check_output.py
@@ -0,0 +1,105 @@
+# Copyright (C) Catalyst IT Ltd. 2017
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+"""
+Blackbox tests for blackboxtest check output methods.
+"""
+
+import time
+import signal
+from samba.tests import BlackboxTestCase
+
+
+class TimeoutHelper():
+    """
+    Timeout class using alarm signal.
+
+    Raise a Timeout exception if a function timeout.
+    Usage:
+
+        try:
+            with Timeout(3):
+                foobar("Request 1")
+        except TimeoutHelper.Timeout:
+            print "Timeout"
+    """
+
+    class Timeout(Exception):
+        pass
+
+    def __init__(self, sec):
+        self.sec = sec
+
+    def __enter__(self):
+        signal.signal(signal.SIGALRM, self.raise_timeout)
+        signal.alarm(self.sec)
+
+    def __exit__(self, *args):
+        signal.alarm(0)    # disable alarm
+
+    def raise_timeout(self, *args):
+        raise TimeoutHelper.Timeout()
+
+
+def _make_cmdline(data='$', repeat=5*1024*1024, retcode=0):
+    """Build a command to call gen_output.py to generate large output"""
+    return 'gen_output.py --data {} --repeat {} --retcode {}'.format(data, repeat, retcode)
+
+
+class CheckOutputTests(BlackboxTestCase):
+    """
+    Blackbox tests for check_xxx methods.
+
+    The check_xxx methods in BlackboxTestCase will deadlock
+    on large output from command which caused by Popen.wait().
+
+    This is a test case to show the deadlock issue,
+    will fix in another commit.
+    """
+
+    def test_check_run_timeout(self):
+        """Call check_run with large output."""
+        try:
+            with TimeoutHelper(10):
+                self.check_run(_make_cmdline())
+        except TimeoutHelper.Timeout:
+            self.fail(msg='Timeout!')
+
+    def test_check_exit_code_with_large_output_success(self):
+        try:
+            with TimeoutHelper(10):
+                self.check_exit_code(_make_cmdline(retcode=0), 0)
+        except TimeoutHelper.Timeout:
+            self.fail(msg='Timeout!')
+
+    def test_check_exit_code_with_large_output_failure(self):
+        try:
+            with TimeoutHelper(10):
+                self.check_exit_code(_make_cmdline(retcode=1), 1)
+        except TimeoutHelper.Timeout:
+            self.fail(msg='Timeout!')
+
+    def test_check_output_with_large_output(self):
+        data = '@'
+        repeat = 5 * 1024 * 1024  # 5M
+        expected = data * repeat
+        cmdline = _make_cmdline(data=data, repeat=repeat)
+
+        try:
+            with TimeoutHelper(10):
+                actual = self.check_output(cmdline)
+                self.assertEqual(actual, expected)
+        except TimeoutHelper.Timeout:
+            self.fail(msg='Timeout!')
diff --git a/python/samba/tests/blackbox/smbcontrol.py b/python/samba/tests/blackbox/smbcontrol.py
new file mode 100644
index 0000000..e151761
--- /dev/null
+++ b/python/samba/tests/blackbox/smbcontrol.py
@@ -0,0 +1,50 @@
+# Blackbox tests for smbcontrol
+#
+# Copyright (C) Catalyst IT Ltd. 2017
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from samba.tests import BlackboxTestCase
+from samba.messaging import Messaging
+
+COMMAND = "bin/smbcontrol"
+PING    = "ping"
+USAGE   = "pool-usage"
+
+
+class SmbcontrolBlockboxTests(BlackboxTestCase):
+
+    def setUp(self):
+        super(SmbcontrolBlockboxTests, self).setUp()
+        lp_ctx = self.get_loadparm()
+        self.msg_ctx = Messaging(lp_ctx=lp_ctx)
+
+    def test_expected_processes(self):
+        """
+        Test that the expected samba processes are running, currently we only
+        check that at least one process is running
+        """
+        processes = self.msg_ctx.irpc_all_servers()
+        if not processes:
+            self.fail("No samba processes returned")
+
+    def test_ping(self):
+        """Test that all the samba processes can be pinged"""
+
+        processes = self.msg_ctx.irpc_all_servers()
+        for p in processes:
+            for id in p.ids:
+                if p.name != "samba":
+                    self.check_run("%s %d %s" % (COMMAND, id.pid, PING))
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index ea23c66..8b2af7f 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -619,6 +619,8 @@ sub provision_raw_step1($$)
 	dreplsrv:periodic_startup_interval = 0
 	dsdb:schema update allowed = yes
 
+        prefork children = 4
+
         vfs objects = dfs_samba4 acl_xattr fake_acls xattr_tdb streams_depot
 
         idmap_ldb:use rfc2307=yes
@@ -2575,7 +2577,7 @@ sub setup_ad_dc_no_ntlm($$)
 		return undef;
 	}
 
-	if (not defined($self->check_or_start($env, "single"))) {
+	if (not defined($self->check_or_start($env, "prefork"))) {
 	    return undef;
 	}
 
diff --git a/selftest/tests.py b/selftest/tests.py
index 3e3ef84..639bc63 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -53,6 +53,7 @@ except ImportError:
 else:
     planpythontestsuite("none", "subunit.tests.test_suite")
 planpythontestsuite("none", "samba.tests.blackbox.ndrdump")
+planpythontestsuite("none", "samba.tests.blackbox.check_output")
 planpythontestsuite("none", "api", name="ldb.python", extra_path=['lib/ldb/tests/python'])
 planpythontestsuite("none", "samba.tests.credentials", py3_compatible=True)
 planpythontestsuite("none", "samba.tests.registry", py3_compatible=True)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 02c3eb6..485d3f7 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -943,6 +943,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 			 "49152-65535");
 	Globals.rpc_low_port = SERVER_TCP_LOW_PORT;
 	Globals.rpc_high_port = SERVER_TCP_HIGH_PORT;
+	Globals.prefork_children = 1;
 
 	/* Now put back the settings that were set with lp_set_cmdline() */
 	apply_lp_set_cmdline();
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index 35a2b99..3f845c7 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -243,5 +243,10 @@ static void cldapd_task_init(struct task_server *task)
 */
 NTSTATUS server_service_cldapd_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "cldap", cldapd_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true
+	};
+	return register_server_service(ctx, "cldap", cldapd_task_init,
+				       &details);
 }
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index d4f5f27..cd293b8 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -642,7 +642,8 @@ static NTSTATUS dns_add_socket(struct dns_server *dns,
 				     &dns_tcp_stream_ops,
 				     "ip", address, &port,
 				     lpcfg_socket_options(dns->task->lp_ctx),
-				     dns_socket);
+				     dns_socket,
+				     dns->task->process_context);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0,("Failed to bind to %s:%u TCP - %s\n",
 			 address, port, nt_errstr(status)));
@@ -683,23 +684,14 @@ static NTSTATUS dns_add_socket(struct dns_server *dns,
   setup our listening sockets on the configured network interfaces
 */
 static NTSTATUS dns_startup_interfaces(struct dns_server *dns,
-				       struct interface *ifaces)
+				       struct interface *ifaces,
+				       const struct model_ops *model_ops)
 {
-	const struct model_ops *model_ops;
 	int num_interfaces;
 	TALLOC_CTX *tmp_ctx = talloc_new(dns);
 	NTSTATUS status;
 	int i;
 
-	/* within the dns task we want to be a single process, so
-	   ask for the single process model ops and pass these to the
-	   stream_setup_socket() call. */
-	model_ops = process_model_startup("single");
-	if (!model_ops) {
-		DEBUG(0,("Can't find 'single' process model_ops\n"));
-		return NT_STATUS_INTERNAL_ERROR;
-	}
-
 	if (ifaces != NULL) {
 		num_interfaces = iface_list_count(ifaces);
 
@@ -906,7 +898,7 @@ static void dns_task_init(struct task_server *task)
 		return;
 	}
 
-	status = dns_startup_interfaces(dns, ifaces);
+	status = dns_startup_interfaces(dns, ifaces, task->model_ops);
 	if (!NT_STATUS_IS_OK(status)) {
 		task_server_terminate(task, "dns failed to setup interfaces", true);
 		return;
@@ -929,5 +921,9 @@ static void dns_task_init(struct task_server *task)
 
 NTSTATUS server_service_dns_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "dns", dns_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true,
+	};
+	return register_server_service(ctx, "dns", dns_task_init, &details);
 }
diff --git a/source4/dsdb/dns/dns_update.c b/source4/dsdb/dns/dns_update.c
index ba8431a..10be7ce 100644
--- a/source4/dsdb/dns/dns_update.c
+++ b/source4/dsdb/dns/dns_update.c
@@ -707,5 +707,10 @@ static void dnsupdate_task_init(struct task_server *task)
 */
 NTSTATUS server_service_dnsupdate_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "dnsupdate", dnsupdate_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true,
+	};
+	return register_server_service(ctx, "dnsupdate", dnsupdate_task_init,
+				       &details);
 }
diff --git a/source4/dsdb/kcc/kcc_service.c b/source4/dsdb/kcc/kcc_service.c
index 946a8fe..a5508af 100644
--- a/source4/dsdb/kcc/kcc_service.c
+++ b/source4/dsdb/kcc/kcc_service.c
@@ -347,5 +347,9 @@ static void kccsrv_task_init(struct task_server *task)
 */
 NTSTATUS server_service_kcc_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "kcc", kccsrv_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true
+	};
+	return register_server_service(ctx, "kcc", kccsrv_task_init, &details);
 }
diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index 0951a0f..8f16a2e 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -528,5 +528,10 @@ static void dreplsrv_task_init(struct task_server *task)
 */
 NTSTATUS server_service_drepl_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "drepl", dreplsrv_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true,
+	};
+	return register_server_service(ctx, "drepl",  dreplsrv_task_init,
+				       &details);
 }
diff --git a/source4/echo_server/echo_server.c b/source4/echo_server/echo_server.c
index e610232..90f8616 100644
--- a/source4/echo_server/echo_server.c
+++ b/source4/echo_server/echo_server.c
@@ -241,34 +241,14 @@ static NTSTATUS echo_add_socket(struct echo_server *echo,
 /* Set up the listening sockets */
 static NTSTATUS echo_startup_interfaces(struct echo_server *echo,
 					struct loadparm_context *lp_ctx,
-					struct interface *ifaces)
+					struct interface *ifaces,
+					const struct model_ops *model_ops)
 {
-	const struct model_ops *model_ops;
 	int num_interfaces;
 	TALLOC_CTX *tmp_ctx = talloc_new(echo);
 	NTSTATUS status;
 	int i;
 
-	/*
-	 * Samba allows subtask to set their own process model.
-	 * Available models currently are:
-	 * - onefork  (forks exactly one child process)
-	 * - prefork  (keep a couple of child processes around)
-	 * - single   (only run a single process)
-	 * - standard (fork one subprocess per incoming connection)
-	 * - thread   (use threads instead of forks)
-	 *
-	 * For the echo server, the "single" process model works fine,
-	 * you probably don't want to use the thread model unless you really
-	 * know what you're doing.
-	 */
-
-	model_ops = process_model_startup("single");
-	if (model_ops == NULL) {
-		DEBUG(0, ("Can't find 'single' process model_ops\n"));
-		return NT_STATUS_INTERNAL_ERROR;
-	}
-
 	num_interfaces = iface_list_count(ifaces);
 
 	for(i=0; i<num_interfaces; i++) {
@@ -327,7 +307,8 @@ static void echo_task_init(struct task_server *task)
 
 	echo->task = task;
 
-	status = echo_startup_interfaces(echo, task->lp_ctx, ifaces);
+	status = echo_startup_interfaces(echo, task->lp_ctx, ifaces,
+					 task->model_ops);
 	if (!NT_STATUS_IS_OK(status)) {
 		task_server_terminate(task, "echo: Failed to set up interfaces",
 				      true);
@@ -343,5 +324,9 @@ static void echo_task_init(struct task_server *task)
  */
 NTSTATUS server_service_echo_init(TALLOC_CTX *ctx)
 {
-	return register_server_service(ctx, "echo", echo_task_init);
+	struct service_details details = {
+		.inhibit_fork_on_accept = true,
+		.inhibit_pre_fork = true
+	};
+	return register_server_service(ctx, "echo", echo_task_init, &details);
 }
diff --git a/source4/kdc/kdc-heimdal.c b/source4/kdc/kdc-heimdal.c
index d5c721b..fcc1eb0 100644
--- a/source4/kdc/kdc-heimdal.c
+++ b/source4/kdc/kdc-heimdal.c
@@ -110,10 +110,11 @@ static kdc_code kdc_process(struct kdc_server *kdc,
 /*
   setup our listening sockets on the configured network interfaces
 */
-static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_context *lp_ctx,
-				       struct interface *ifaces)
+static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list