summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-10-30 11:24:15 +1100
committerAndrew Tridgell <tridge@samba.org>2010-10-30 23:49:00 +1100
commit046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8 (patch)
tree3212537bdd1e74cc2153aacb229cab99e2e290db /source4
parent3a7814826989b2ece34b8370c77bce9727814701 (diff)
downloadsamba-046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8.tar.gz
samba-046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8.tar.bz2
samba-046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8.zip
s4-smbd: don't initialise process models more than once
this also removes the event_context parameter from process model initialisation. It isn't needed, and is confusing when a process model init can be called from more than one place, possibly with different event contexts. Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/dns_server/dns_server.c2
-rw-r--r--source4/kdc/kdc.c2
-rw-r--r--source4/ldap_server/ldap_server.c2
-rw-r--r--source4/ntp_signd/ntp_signd.c2
-rw-r--r--source4/rpc_server/service_rpc.c2
-rw-r--r--source4/smb_server/smb_samba3.c2
-rw-r--r--source4/smbd/process_model.c62
-rw-r--r--source4/smbd/process_model.h5
-rw-r--r--source4/smbd/process_onefork.c2
-rw-r--r--source4/smbd/process_prefork.c2
-rw-r--r--source4/smbd/process_single.c2
-rw-r--r--source4/smbd/process_standard.c2
-rw-r--r--source4/smbd/process_thread.c4
-rw-r--r--source4/smbd/service.c2
-rw-r--r--source4/torture/rpc/spoolss_notify.c4
-rw-r--r--source4/web_server/web_server.c2
-rw-r--r--source4/winbind/wb_server.c2
-rw-r--r--source4/wrepl_server/wrepl_in_connection.c4
18 files changed, 55 insertions, 50 deletions
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index 635cd9507f..8e37fc21d3 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -550,7 +550,7 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns, struct loadparm_c
/* 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(dns->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c
index 3242258e23..a4bab42920 100644
--- a/source4/kdc/kdc.c
+++ b/source4/kdc/kdc.c
@@ -537,7 +537,7 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
/* 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(kdc->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index ba5a268e8e..38e8959883 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -899,7 +899,7 @@ static void ldapsrv_task_init(struct task_server *task)
task_server_set_title(task, "task[ldapsrv]");
/* run the ldap server as a single process */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
ldap_service = talloc_zero(task, struct ldapsrv_service);
diff --git a/source4/ntp_signd/ntp_signd.c b/source4/ntp_signd/ntp_signd.c
index ae3eeb93f7..a0dd2d3065 100644
--- a/source4/ntp_signd/ntp_signd.c
+++ b/source4/ntp_signd/ntp_signd.c
@@ -503,7 +503,7 @@ static void ntp_signd_task_init(struct task_server *task)
/* 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(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return;
diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c
index 82d6d9be6e..dfe25b75c6 100644
--- a/source4/rpc_server/service_rpc.c
+++ b/source4/rpc_server/service_rpc.c
@@ -56,7 +56,7 @@ static void dcesrv_task_init(struct task_server *task)
/* run the rpc server as a single process to allow for shard
* handles, and sharing of ldb contexts */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
status = dcesrv_init_context(task->event_ctx,
diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c
index 5af2ce5042..df85bcf900 100644
--- a/source4/smb_server/smb_samba3.c
+++ b/source4/smb_server/smb_samba3.c
@@ -119,7 +119,7 @@ static void samba3_smb_task_init(struct task_server *task)
NTSTATUS status;
const struct model_ops *model_ops;
- model_ops = process_model_startup(task->event_ctx, "standard");
+ model_ops = process_model_startup("standard");
if (model_ops == NULL) {
goto failed;
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index d3f234eb41..0e63605460 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -22,32 +22,52 @@
#include "smbd/process_model.h"
#include "param/param.h"
-static const struct model_ops *process_model_byname(const char *name);
+/* the list of currently registered process models */
+static struct process_model {
+ struct model_ops *ops;
+ bool initialised;
+} *models = NULL;
+static int num_models;
+
+
+/*
+ return the operations structure for a named backend of the specified type
+*/
+static struct process_model *process_model_byname(const char *name)
+{
+ int i;
+
+ for (i=0;i<num_models;i++) {
+ if (strcmp(models[i].ops->name, name) == 0) {
+ return &models[i];
+ }
+ }
+
+ return NULL;
+}
+
/*
setup the events for the chosen process model
*/
-_PUBLIC_ const struct model_ops *process_model_startup(struct tevent_context *ev, const char *model)
+_PUBLIC_ const struct model_ops *process_model_startup(const char *model)
{
- const struct model_ops *ops;
+ struct process_model *m;
- ops = process_model_byname(model);
- if (!ops) {
+ m = process_model_byname(model);
+ if (m == NULL) {
DEBUG(0,("Unknown process model '%s'\n", model));
exit(-1);
}
- ops->model_init(ev);
+ if (!m->initialised) {
+ m->initialised = true;
+ m->ops->model_init();
+ }
- return ops;
+ return m->ops;
}
-/* the list of currently registered process models */
-static struct process_model {
- struct model_ops *ops;
-} *models = NULL;
-static int num_models;
-
/*
register a process model.
@@ -100,22 +120,6 @@ _PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx)
}
/*
- return the operations structure for a named backend of the specified type
-*/
-static const struct model_ops *process_model_byname(const char *name)
-{
- int i;
-
- for (i=0;i<num_models;i++) {
- if (strcmp(models[i].ops->name, name) == 0) {
- return models[i].ops;
- }
- }
-
- return NULL;
-}
-
-/*
return the PROCESS_MODEL module version, and the size of some critical types
This can be used by process model modules to either detect compilation errors, or provide
multiple implementations for different smbd compilation options in one module
diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h
index 1d3e32eb34..b5790316ec 100644
--- a/source4/smbd/process_model.h
+++ b/source4/smbd/process_model.h
@@ -26,6 +26,7 @@
#include "lib/socket/socket.h"
#include "smbd/service.h"
+#include "smbd/process_model_proto.h"
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
@@ -41,7 +42,7 @@ struct model_ops {
const char *name;
/* called at startup when the model is selected */
- void (*model_init)(struct tevent_context *);
+ void (*model_init)(void);
/* function to accept new connection */
void (*accept_connection)(struct tevent_context *,
@@ -78,7 +79,7 @@ struct process_model_critical_sizes {
extern const struct model_ops single_ops;
-const struct model_ops *process_model_startup(struct tevent_context *ev, const char *model);
+const struct model_ops *process_model_startup(const char *model);
NTSTATUS register_process_model(const void *_ops);
NTSTATUS process_model_init(struct loadparm_context *lp_ctx);
diff --git a/source4/smbd/process_onefork.c b/source4/smbd/process_onefork.c
index b0e2e29bd6..da34f73164 100644
--- a/source4/smbd/process_onefork.c
+++ b/source4/smbd/process_onefork.c
@@ -49,7 +49,7 @@ static int none_setproctitle(const char *fmt, ...)
/*
called when the process model is selected
*/
-static void onefork_model_init(struct tevent_context *ev)
+static void onefork_model_init(void)
{
signal(SIGCHLD, SIG_IGN);
}
diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c
index 64941dbeb5..1340464381 100644
--- a/source4/smbd/process_prefork.c
+++ b/source4/smbd/process_prefork.c
@@ -49,7 +49,7 @@ static int none_setproctitle(const char *fmt, ...)
/*
called when the process model is selected
*/
-static void prefork_model_init(struct tevent_context *ev)
+static void prefork_model_init(void)
{
signal(SIGCHLD, SIG_IGN);
}
diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c
index 688b46e0a0..7678a912f9 100644
--- a/source4/smbd/process_single.c
+++ b/source4/smbd/process_single.c
@@ -29,7 +29,7 @@
/*
called when the process model is selected
*/
-static void single_model_init(struct tevent_context *ev)
+static void single_model_init(void)
{
}
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 5ee8e6948d..99e815a160 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -50,7 +50,7 @@ static int child_pipe[2];
/*
called when the process model is selected
*/
-static void standard_model_init(struct tevent_context *ev)
+static void standard_model_init(void)
{
pipe(child_pipe);
signal(SIGCHLD, SIG_IGN);
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c
index b169a79222..cf94234c34 100644
--- a/source4/smbd/process_thread.c
+++ b/source4/smbd/process_thread.c
@@ -511,7 +511,7 @@ static void thread_fault_handler(int sig)
/*
called when the process model is selected
*/
-static void thread_model_init(struct tevent_context *event_context)
+static void thread_model_init(void)
{
struct mutex_ops m_ops;
struct debug_ops d_ops;
@@ -520,7 +520,7 @@ static void thread_model_init(struct tevent_context *event_context)
ZERO_STRUCT(d_ops);
pthread_key_create(&title_key, NULL);
- pthread_setspecific(title_key, talloc_strdup(event_context, ""));
+ pthread_setspecific(title_key, NULL);
/* register mutex/rwlock handlers */
m_ops.mutex_init = thread_mutex_init;
diff --git a/source4/smbd/service.c b/source4/smbd/service.c
index 7b53e9fa4e..9cdbbc28f3 100644
--- a/source4/smbd/service.c
+++ b/source4/smbd/service.c
@@ -83,7 +83,7 @@ NTSTATUS server_service_startup(struct tevent_context *event_ctx,
return NT_STATUS_INVALID_PARAMETER;
}
- model_ops = process_model_startup(event_ctx, model);
+ model_ops = process_model_startup(model);
if (!model_ops) {
DEBUG(0,("process_model_startup('%s') failed\n", model));
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
index 8e23637442..4608f1f09d 100644
--- a/source4/torture/rpc/spoolss_notify.c
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -460,7 +460,7 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
torture_comment(tctx, "Listening for callbacks on %s\n", address);
- status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, &single_ops, address);
+ status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, process_model_startup("single"), address);
torture_assert_ntstatus_ok(tctx, status, "starting smb server");
status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints, &dce_ctx);
@@ -469,7 +469,7 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
for (e=dce_ctx->endpoint_list;e;e=e->next) {
status = dcesrv_add_ep(dce_ctx, tctx->lp_ctx,
- e, tctx->ev, &single_ops);
+ e, tctx->ev, process_model_startup("single"));
torture_assert_ntstatus_ok(tctx, status,
"unable listen on dcerpc endpoint server");
}
diff --git a/source4/web_server/web_server.c b/source4/web_server/web_server.c
index f40f0a625b..97e65e5a47 100644
--- a/source4/web_server/web_server.c
+++ b/source4/web_server/web_server.c
@@ -307,7 +307,7 @@ static void websrv_task_init(struct task_server *task)
task_server_set_title(task, "task[websrv]");
/* run the web server as a single process */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
if (lpcfg_interfaces(task->lp_ctx) && lpcfg_bind_interfaces_only(task->lp_ctx)) {
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index 184b1162c1..34d145d318 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -205,7 +205,7 @@ static void winbind_task_init(struct task_server *task)
/* within the winbind 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(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
task_server_terminate(task,
"Can't find 'single' process model_ops", true);
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c
index a32b842e04..632c9a9a5b 100644
--- a/source4/wrepl_server/wrepl_in_connection.c
+++ b/source4/wrepl_server/wrepl_in_connection.c
@@ -357,7 +357,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
/* 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(service->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops"));
return NT_STATUS_INTERNAL_ERROR;
@@ -430,7 +430,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
/* 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(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops"));
return NT_STATUS_INTERNAL_ERROR;