From 046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 30 Oct 2010 11:24:15 +1100 Subject: 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 --- source4/smbd/process_model.c | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'source4/smbd/process_model.c') 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;iname, 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. @@ -99,22 +119,6 @@ _PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx) return NT_STATUS_OK; } -/* - 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;iname, 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 -- cgit