summaryrefslogtreecommitdiff
path: root/source4/smbd/process_model.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-02-02 13:43:03 +0000
committerStefan Metzmacher <metze@samba.org>2004-02-02 13:43:03 +0000
commitc61089219b82ff94f83e1fb428e8b47ad778c868 (patch)
tree2109fd566da9e1492a03c817cf83c71b2140ce52 /source4/smbd/process_model.c
parent894e02f80c254da4edca5dbae99561d205c63fbe (diff)
downloadsamba-c61089219b82ff94f83e1fb428e8b47ad778c868.tar.gz
samba-c61089219b82ff94f83e1fb428e8b47ad778c868.tar.bz2
samba-c61089219b82ff94f83e1fb428e8b47ad778c868.zip
- we now specify the object files in the subsystems config.m4 file
I plan to convert all objectfile group to use SMB_SUBSYSTEM later I'll add a SMB_BINARY() and SMB_LIBRARY(), then there will be no more need to touch Makefile.in, because all make rules will be autogenerated by configure - convert the PROCESS_MODEL subsystem to this new scheme and move the pthread test to smbd/process_model.m4 - convert the CHARSET subsystem to this new scheme and move the iconv test to lib/iconv.m4 (This used to be commit 2e57ee884ebea194ee79ac20e84e385481b56aa2)
Diffstat (limited to 'source4/smbd/process_model.c')
-rw-r--r--source4/smbd/process_model.c64
1 files changed, 47 insertions, 17 deletions
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index 06127d1364..121b35aba4 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -24,7 +24,6 @@
/* the list of currently registered process models */
static struct {
- const char *name;
struct model_ops *ops;
} *models = NULL;
static int num_models;
@@ -35,13 +34,15 @@ static int num_models;
The 'name' can be later used by other backends to find the operations
structure for this backend.
*/
-BOOL register_process_model(const char *name, struct model_ops *ops)
+static NTSTATUS register_process_model(void *_ops)
{
- if (process_model_byname(name) != NULL) {
+ const struct model_ops *ops = _ops;
+
+ if (process_model_byname(ops->name) != NULL) {
/* its already registered! */
- DEBUG(2,("process_model '%s' already registered\n",
- name));
- return False;
+ DEBUG(0,("PROCESS_MODEL '%s' already registered\n",
+ ops->name));
+ return NT_STATUS_OBJECT_NAME_COLLISION;
}
models = Realloc(models, sizeof(models[0]) * (num_models+1));
@@ -49,23 +50,26 @@ BOOL register_process_model(const char *name, struct model_ops *ops)
smb_panic("out of memory in register_process_model");
}
- models[num_models].name = smb_xstrdup(name);
models[num_models].ops = smb_xmemdup(ops, sizeof(*ops));
+ models[num_models].ops->name = smb_xstrdup(ops->name);
num_models++;
- return True;
+ DEBUG(3,("PROCESS_MODEL '%s' registered\n",
+ ops->name));
+
+ return NT_STATUS_OK;
}
/*
return the operations structure for a named backend of the specified type
*/
-struct model_ops *process_model_byname(const char *name)
+const struct model_ops *process_model_byname(const char *name)
{
int i;
for (i=0;i<num_models;i++) {
- if (strcmp(models[i].name, name) == 0) {
+ if (strcmp(models[i].ops->name, name) == 0) {
return models[i].ops;
}
}
@@ -73,13 +77,39 @@ struct model_ops *process_model_byname(const char *name)
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
+*/
+const struct process_model_critical_sizes *process_model_version(void)
+{
+ static const struct process_model_critical_sizes critical_sizes = {
+ PROCESS_MODEL_VERSION,
+ sizeof(struct model_ops),
+ sizeof(struct server_context),
+ sizeof(struct event_context),
+ sizeof(struct fd_event)
+ };
+
+ return &critical_sizes;
+}
-/* initialise the builtin process models */
-void process_model_init(void)
+/*
+ initialise the PROCESS_MODEL subsystem
+*/
+BOOL process_model_init(void)
{
- process_model_standard_init();
- process_model_single_init();
-#ifdef WITH_PTHREADS
- process_model_thread_init();
-#endif
+ NTSTATUS status;
+
+ status = register_subsystem("process_model", register_process_model);
+ if (!NT_STATUS_IS_OK(status)) {
+ return False;
+ }
+
+ /* FIXME: Perhaps panic if a basic process model, such as simple, fails to initialise? */
+ static_init_process_model;
+
+ DEBUG(3,("PROCESS subsystem version %d initialised\n", PROCESS_MODEL_VERSION));
+ return True;
}