summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Lockyer <gary@catalyst.net.nz>2017-09-18 13:05:24 +1200
committerAndrew Bartlett <abartlet@samba.org>2017-10-19 05:33:10 +0200
commit08402526704c6d586febadf401959bc3d8661836 (patch)
tree2ef36fcacab16df9d7a9c3aef1b18e7643a97cc8
parent62d7bf9e0ae94baaaa090051bd6b7cb40e5ef3c3 (diff)
downloadsamba-08402526704c6d586febadf401959bc3d8661836.tar.gz
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@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
-rw-r--r--source4/dns_server/dns_server.c15
-rw-r--r--source4/echo_server/echo_server.c27
-rw-r--r--source4/kdc/kdc-heimdal.c19
-rw-r--r--source4/kdc/kdc-service-mit.c6
-rw-r--r--source4/ldap_server/ldap_server.c18
-rw-r--r--source4/ntp_signd/ntp_signd.c13
-rw-r--r--source4/web_server/web_server.c13
-rw-r--r--source4/wrepl_server/wrepl_in_connection.c44
8 files changed, 39 insertions, 116 deletions
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index 6a90e3089f5..cd293b82522 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -684,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);
@@ -907,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;
diff --git a/source4/echo_server/echo_server.c b/source4/echo_server/echo_server.c
index 9a66211ebe8..90f8616ca11 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);
diff --git a/source4/kdc/kdc-heimdal.c b/source4/kdc/kdc-heimdal.c
index 788959a737a..fcc1eb02edf 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,
+ struct loadparm_context *lp_ctx,
+ struct interface *ifaces,
+ const struct model_ops *model_ops)
{
- const struct model_ops *model_ops;
int num_interfaces;
TALLOC_CTX *tmp_ctx = talloc_new(kdc);
NTSTATUS status;
@@ -122,15 +123,6 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
uint16_t kpasswd_port = lpcfg_kpasswd_port(lp_ctx);
bool done_wildcard = false;
- /* within the kdc 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;
- }
-
num_interfaces = iface_list_count(ifaces);
/* if we are allowing incoming packets from any address, then
@@ -448,7 +440,8 @@ static void kdc_task_init(struct task_server *task)
kdc->private_data = kdc_config;
/* start listening on the configured network interfaces */
- status = kdc_startup_interfaces(kdc, task->lp_ctx, ifaces);
+ status = kdc_startup_interfaces(kdc, task->lp_ctx, ifaces,
+ task->model_ops);
if (!NT_STATUS_IS_OK(status)) {
task_server_terminate(task, "kdc failed to setup interfaces", true);
return;
diff --git a/source4/kdc/kdc-service-mit.c b/source4/kdc/kdc-service-mit.c
index d48b0328882..53997d5473d 100644
--- a/source4/kdc/kdc-service-mit.c
+++ b/source4/kdc/kdc-service-mit.c
@@ -72,12 +72,6 @@ static NTSTATUS startup_kpasswd_server(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
- model_ops = process_model_startup("single");
- if (model_ops == NULL) {
- DBG_ERR("Can't find 'single' process model_ops\n");
- return NT_STATUS_INTERNAL_ERROR;
- }
-
tmp_ctx = talloc_named_const(mem_ctx, 0, "kpasswd");
if (tmp_ctx == NULL) {
return NT_STATUS_NO_MEMORY;
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index d12c4e70e02..5f7efe90bba 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -1112,7 +1112,6 @@ static void ldapsrv_task_init(struct task_server *task)
const char *dns_host_name;
struct ldapsrv_service *ldap_service;
NTSTATUS status;
- const struct model_ops *model_ops;
switch (lpcfg_server_role(task->lp_ctx)) {
case ROLE_STANDALONE:
@@ -1130,13 +1129,6 @@ static void ldapsrv_task_init(struct task_server *task)
task_server_set_title(task, "task[ldapsrv]");
- /*
- * Here we used to run the ldap server as a single process,
- * but we don't want transaction locks for one task in a write
- * blocking all other reads, so we go multi-process.
- */
- model_ops = task->model_ops;
-
ldap_service = talloc_zero(task, struct ldapsrv_service);
if (ldap_service == NULL) goto failed;
@@ -1180,7 +1172,8 @@ static void ldapsrv_task_init(struct task_server *task)
*/
for(i = 0; i < num_interfaces; i++) {
const char *address = iface_list_n_ip(ifaces, i);
- status = add_socket(task, task->lp_ctx, model_ops, address, ldap_service);
+ status = add_socket(task, task->lp_ctx, task->model_ops,
+ address, ldap_service);
if (!NT_STATUS_IS_OK(status)) goto failed;
}
} else {
@@ -1193,7 +1186,8 @@ static void ldapsrv_task_init(struct task_server *task)
goto failed;
}
for (i=0; wcard[i]; i++) {
- status = add_socket(task, task->lp_ctx, model_ops, wcard[i], ldap_service);
+ status = add_socket(task, task->lp_ctx, task->model_ops,
+ wcard[i], ldap_service);
if (NT_STATUS_IS_OK(status)) {
num_binds++;
}
@@ -1210,7 +1204,7 @@ static void ldapsrv_task_init(struct task_server *task)
}
status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
- model_ops, &ldap_stream_nonpriv_ops,
+ task->model_ops, &ldap_stream_nonpriv_ops,
"unix", ldapi_path, NULL,
lpcfg_socket_options(task->lp_ctx),
ldap_service, task->process_context);
@@ -1241,7 +1235,7 @@ static void ldapsrv_task_init(struct task_server *task)
}
status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
- model_ops, &ldap_stream_priv_ops,
+ task->model_ops, &ldap_stream_priv_ops,
"unix", ldapi_path, NULL,
lpcfg_socket_options(task->lp_ctx),
ldap_service,
diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c
index 0884d2f53b5..e09c69346e0 100644
--- a/source4/ntp_signd/ntp_signd.c
+++ b/source4/ntp_signd/ntp_signd.c
@@ -494,8 +494,6 @@ static void ntp_signd_task_init(struct task_server *task)
struct ntp_signd_server *ntp_signd;
NTSTATUS status;
- const struct model_ops *model_ops;
-
const char *address;
if (!directory_create_or_exist_strict(lpcfg_ntp_signd_socket_directory(task->lp_ctx), geteuid(), 0750)) {
@@ -506,15 +504,6 @@ static void ntp_signd_task_init(struct task_server *task)
return;
}
- /* within the ntp_signd 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;
- }
-
task_server_set_title(task, "task[ntp_signd]");
ntp_signd = talloc(task, struct ntp_signd_server);
@@ -537,7 +526,7 @@ static void ntp_signd_task_init(struct task_server *task)
status = stream_setup_socket(ntp_signd->task,
ntp_signd->task->event_ctx,
ntp_signd->task->lp_ctx,
- model_ops,
+ task->model_ops,
&ntp_signd_stream_ops,
"unix", address, NULL,
lpcfg_socket_options(ntp_signd->task->lp_ctx),
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index faf1bc65650..c3516890eb7 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -298,15 +298,10 @@ static void websrv_task_init(struct task_server *task)
{
NTSTATUS status;
uint16_t port = lpcfg_web_port(task->lp_ctx);
- const struct model_ops *model_ops;
struct web_server_data *wdata;
task_server_set_title(task, "task[websrv]");
- /* run the web server as a single process */
- model_ops = process_model_startup("single");
- if (!model_ops) goto failed;
-
/* startup the Python processor - unfortunately we can't do this
per connection as that wouldn't allow for session variables */
wdata = talloc_zero(task, struct web_server_data);
@@ -327,8 +322,9 @@ static void websrv_task_init(struct task_server *task)
const char *address = iface_list_n_ip(ifaces, i);
status = stream_setup_socket(task,
task->event_ctx,
- task->lp_ctx, model_ops,
- &web_stream_ops,
+ task->lp_ctx,
+ task->model_ops,
+ &web_stream_ops,
"ip", address,
&port,
lpcfg_socket_options(task->lp_ctx),
@@ -348,7 +344,8 @@ static void websrv_task_init(struct task_server *task)
}
for (i=0; wcard[i]; i++) {
status = stream_setup_socket(task, task->event_ctx,
- task->lp_ctx, model_ops,
+ task->lp_ctx,
+ task->model_ops,
&web_stream_ops,
"ip", wcard[i],
&port, lpcfg_socket_options(task->lp_ctx),
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c
index 4920aa0328f..5cbb086a8db 100644
--- a/source4/wrepl_server/wrepl_in_connection.c
+++ b/source4/wrepl_server/wrepl_in_connection.c
@@ -352,20 +352,10 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
{
struct wreplsrv_service *service = partner->service;
struct wreplsrv_in_connection *wrepl_in;
- const struct model_ops *model_ops;
struct stream_connection *conn;
struct tevent_req *subreq;
NTSTATUS status;
- /* within the wrepl 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"));
- return NT_STATUS_INTERNAL_ERROR;
- }
-
wrepl_in = talloc_zero(partner, struct wreplsrv_in_connection);
NT_STATUS_HAVE_NO_MEMORY(wrepl_in);
@@ -376,7 +366,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
status = stream_new_connection_merge(service->task->event_ctx,
service->task->lp_ctx,
- model_ops,
+ service->task->model_ops,
&wreplsrv_stream_ops,
service->task->msg_ctx,
wrepl_in,
@@ -427,19 +417,9 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
{
NTSTATUS status;
struct task_server *task = service->task;
- const struct model_ops *model_ops;
const char *address;
uint16_t port = WINS_REPLICATION_PORT;
- /* within the wrepl 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"));
- return NT_STATUS_INTERNAL_ERROR;
- }
-
if (lpcfg_interfaces(lp_ctx) && lpcfg_bind_interfaces_only(lp_ctx)) {
int num_interfaces;
int i;
@@ -458,12 +438,14 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
continue;
}
address = iface_list_n_ip(ifaces, i);
- status = stream_setup_socket(task, task->event_ctx,
- task->lp_ctx, model_ops,
- &wreplsrv_stream_ops,
- "ipv4", address, &port,
- lpcfg_socket_options(task->lp_ctx),
- service, task->process_context);
+ status = stream_setup_socket(
+ task, task->event_ctx,
+ task->lp_ctx,
+ task->model_ops,
+ &wreplsrv_stream_ops,
+ "ipv4", address, &port,
+ lpcfg_socket_options(task->lp_ctx),
+ service, task->process_context);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",
address, port, nt_errstr(status)));
@@ -472,9 +454,11 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
}
} else {
address = "0.0.0.0";
- status = stream_setup_socket(task, task->event_ctx, task->lp_ctx,
- model_ops, &wreplsrv_stream_ops,
- "ipv4", address, &port, lpcfg_socket_options(task->lp_ctx),
+ status = stream_setup_socket(task, task->event_ctx,
+ task->lp_ctx, task->model_ops,
+ &wreplsrv_stream_ops,
+ "ipv4", address, &port,
+ lpcfg_socket_options(task->lp_ctx),
service, task->process_context);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("stream_setup_socket(address=%s,port=%u) failed - %s\n",