summaryrefslogtreecommitdiffstats
path: root/source4/smbd
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
parent894e02f80c254da4edca5dbae99561d205c63fbe (diff)
downloadsamba-c61089219b82ff94f83e1fb428e8b47ad778c868.tar.gz
samba-c61089219b82ff94f83e1fb428e8b47ad778c868.tar.xz
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')
-rw-r--r--source4/smbd/process_model.c64
-rw-r--r--source4/smbd/process_model.h69
-rw-r--r--source4/smbd/process_model.m427
-rw-r--r--source4/smbd/process_single.c27
-rw-r--r--source4/smbd/process_standard.c26
-rw-r--r--source4/smbd/process_thread.c28
-rw-r--r--source4/smbd/server.c4
7 files changed, 208 insertions, 37 deletions
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index 06127d13645..121b35aba44 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;
}
diff --git a/source4/smbd/process_model.h b/source4/smbd/process_model.h
new file mode 100644
index 00000000000..688ae652262
--- /dev/null
+++ b/source4/smbd/process_model.h
@@ -0,0 +1,69 @@
+/*
+ Unix SMB/CIFS implementation.
+ process model manager - main loop
+ Copyright (C) Andrew Tridgell 1992-2003
+ Copyright (C) James J Myers 2003 <myersjj@samba.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef SAMBA_PROCESS_MODEL_H
+#define SAMBA_PROCESS_MODEL_H
+
+/* modules can use the following to determine if the interface has changed
+ * please increment the version number after each interface change
+ * with a comment and maybe update struct process_model_critical_sizes.
+ */
+/* version 1 - initial version - metze */
+#define PROCESS_MODEL_VERSION 1
+
+/* the process model operations structure - contains function pointers to
+ the model-specific implementations of each operation */
+struct model_ops {
+ /* the name of the process_model */
+ const char *name;
+
+ /* called at startup when the model is selected */
+ void (*model_startup)(void);
+
+ /* function to accept new connection */
+ void (*accept_connection)(struct event_context *, struct fd_event *, time_t, uint16);
+
+ /* function to accept new rpc over tcp connection */
+ void (*accept_rpc_connection)(struct event_context *, struct fd_event *, time_t, uint16);
+
+ /* function to terminate a connection */
+ void (*terminate_connection)(struct server_context *smb, const char *reason);
+
+ /* function to terminate a connection */
+ void (*terminate_rpc_connection)(void *r, const char *reason);
+
+ /* function to exit server */
+ void (*exit_server)(struct server_context *smb, const char *reason);
+
+ /* returns process or thread id */
+ int (*get_id)(struct request_context *req);
+};
+
+/* this structure is used by modules to determine the size of some critical types */
+struct process_model_critical_sizes {
+ int interface_version;
+ int sizeof_model_ops;
+ int sizeof_server_context;
+ int sizeof_event_context;
+ int sizeof_fd_event;
+};
+
+#endif /* SAMBA_PROCESS_MODEL_H */
diff --git a/source4/smbd/process_model.m4 b/source4/smbd/process_model.m4
new file mode 100644
index 00000000000..a7f6fb07931
--- /dev/null
+++ b/source4/smbd/process_model.m4
@@ -0,0 +1,27 @@
+dnl # Server process model subsystem
+
+SMB_MODULE(process_model_single,PROCESS_MODEL,STATIC,[smbd/process_single.o])
+SMB_MODULE(process_model_standard,PROCESS_MODEL,STATIC,[smbd/process_standard.o])
+
+#################################################
+# check for pthread support
+AC_MSG_CHECKING(whether to use pthreads)
+AC_ARG_WITH(pthreads,
+[ --with-pthreads Include pthreads (default=no) ],
+[ case "$withval" in
+ yes)
+ AC_MSG_RESULT(yes)
+ SMB_MODULE_DEFAULT(process_model_thread,STATIC)
+ ;;
+ *)
+ AC_MSG_RESULT(no)
+ ;;
+ esac ],
+AC_MSG_RESULT(no)
+)
+
+SMB_MODULE(process_model_thread,PROCESS_MODEL,NOT,
+ [smbd/process_thread.o],[],[-lpthread])
+
+SMB_SUBSYSTEM(PROCESS_MODEL,smbd/process_model.o,
+ [],smbd/process_model_public_proto.h)
diff --git a/source4/smbd/process_single.c b/source4/smbd/process_single.c
index 8f1362bed3d..0c626e45c63 100644
--- a/source4/smbd/process_single.c
+++ b/source4/smbd/process_single.c
@@ -92,24 +92,39 @@ static int get_id(struct request_context *req)
return (int)req->smb->pid;
}
+static void single_exit_server(struct server_context *smb, const char *reason)
+{
+ DEBUG(1,("single_exit_server: reason[%s]\n",reason));
+}
+
/*
- initialise the single process model, registering ourselves with the model subsystem
+ initialise the single process model, registering ourselves with the process model subsystem
*/
-void process_model_single_init(void)
+NTSTATUS process_model_single_init(void)
{
+ NTSTATUS ret;
struct model_ops ops;
ZERO_STRUCT(ops);
-
+
+ /* fill in our name */
+ ops.name = "single";
+
/* fill in all the operations */
ops.model_startup = model_startup;
ops.accept_connection = accept_connection;
ops.accept_rpc_connection = accept_rpc_connection;
ops.terminate_connection = terminate_connection;
ops.terminate_rpc_connection = terminate_rpc_connection;
- ops.exit_server = NULL;
+ ops.exit_server = single_exit_server;
ops.get_id = get_id;
- /* register ourselves with the process model subsystem. We register under the name 'single'. */
- register_process_model("single", &ops);
+ /* register ourselves with the PROCESS_MODEL subsystem. */
+ ret = register_backend("process_model", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register process_model 'single'!\n"));
+ return ret;
+ }
+
+ return ret;
}
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 505c2aafbf7..8a71739d2a5 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -134,23 +134,39 @@ static int get_id(struct request_context *req)
return (int)req->smb->pid;
}
+static void standard_exit_server(struct server_context *smb, const char *reason)
+{
+ DEBUG(1,("standard_exit_server: reason[%s]\n",reason));
+}
+
/*
- initialise the standard process model, registering ourselves with the model subsystem
+ initialise the standard process model, registering ourselves with the process model subsystem
*/
-void process_model_standard_init(void)
+NTSTATUS process_model_standard_init(void)
{
+ NTSTATUS ret;
struct model_ops ops;
ZERO_STRUCT(ops);
-
+
+ /* fill in our name */
+ ops.name = "standard";
+
/* fill in all the operations */
ops.model_startup = model_startup;
ops.accept_connection = accept_connection;
ops.accept_rpc_connection = accept_rpc_connection;
ops.terminate_connection = terminate_connection;
ops.terminate_rpc_connection = terminate_rpc_connection;
+ ops.exit_server = standard_exit_server;
ops.get_id = get_id;
- /* register ourselves with the process model subsystem. We register under the name 'standard'. */
- register_process_model("standard", &ops);
+ /* register ourselves with the PROCESS_MODEL subsystem. */
+ ret = register_backend("process_model", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register process_model 'standard'!\n"));
+ return ret;
+ }
+
+ return ret;
}
diff --git a/source4/smbd/process_thread.c b/source4/smbd/process_thread.c
index bd641663551..dcd2f456af5 100644
--- a/source4/smbd/process_thread.c
+++ b/source4/smbd/process_thread.c
@@ -465,25 +465,39 @@ static void model_startup(void)
register_debug_handlers("thread", &d_ops);
}
+static void thread_exit_server(struct server_context *smb, const char *reason)
+{
+ DEBUG(1,("thread_exit_server: reason[%s]\n",reason));
+}
+
/*
initialise the thread process model, registering ourselves with the model subsystem
*/
-void process_model_thread_init(void)
+NTSTATUS process_model_thread_init(void)
{
+ NTSTATUS ret;
struct model_ops ops;
ZERO_STRUCT(ops);
-
+
+ /* fill in our name */
+ ops.name = "thread";
+
/* fill in all the operations */
ops.model_startup = model_startup;
ops.accept_connection = accept_connection;
ops.accept_rpc_connection = accept_rpc_connection;
ops.terminate_connection = terminate_connection;
ops.terminate_rpc_connection = terminate_rpc_connection;
- ops.exit_server = NULL;
+ ops.exit_server = thread_exit_server;
ops.get_id = get_id;
-
- /* register ourselves with the process model subsystem. We
- register under the name 'thread'. */
- register_process_model("thread", &ops);
+
+ /* register ourselves with the PROCESS_MODEL subsystem. */
+ ret = register_backend("process_model", &ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register process_model 'thread'!\n"));
+ return ret;
+ }
+
+ return ret;
}
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index 67bf07c7f87..2ed74a8c4d4 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -91,7 +91,7 @@ static void add_socket(struct event_context *events,
Open the socket communication.
****************************************************************************/
static void open_sockets_smbd(struct event_context *events,
- struct model_ops *model_ops)
+ const struct model_ops *model_ops)
{
if (lp_interfaces() && lp_bind_interfaces_only()) {
int num_interfaces = iface_count();
@@ -194,7 +194,7 @@ static BOOL init_structs(void)
static void setup_process_model(struct event_context *events,
const char *model)
{
- struct model_ops *ops;
+ const struct model_ops *ops;
process_model_init();