summaryrefslogtreecommitdiff
path: root/source4/smbd/process_model.c
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/smbd/process_model.c
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/smbd/process_model.c')
-rw-r--r--source4/smbd/process_model.c62
1 files changed, 33 insertions, 29 deletions
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