diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-10-30 11:24:15 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-10-30 23:49:00 +1100 |
commit | 046d38faa5e78f2bdcfcdb3b1582427c2ecc80b8 (patch) | |
tree | 3212537bdd1e74cc2153aacb229cab99e2e290db /source4/smbd | |
parent | 3a7814826989b2ece34b8370c77bce9727814701 (diff) | |
download | samba-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')
-rw-r--r-- | source4/smbd/process_model.c | 62 | ||||
-rw-r--r-- | source4/smbd/process_model.h | 5 | ||||
-rw-r--r-- | source4/smbd/process_onefork.c | 2 | ||||
-rw-r--r-- | source4/smbd/process_prefork.c | 2 | ||||
-rw-r--r-- | source4/smbd/process_single.c | 2 | ||||
-rw-r--r-- | source4/smbd/process_standard.c | 2 | ||||
-rw-r--r-- | source4/smbd/process_thread.c | 4 | ||||
-rw-r--r-- | source4/smbd/service.c | 2 |
8 files changed, 43 insertions, 38 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 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; |