/* within the dns task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(dns->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return NT_STATUS_INTERNAL_ERROR;
/* within the kdc task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(kdc->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return NT_STATUS_INTERNAL_ERROR;
task_server_set_title(task, "task[ldapsrv]");
/* run the ldap server as a single process */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
ldap_service = talloc_zero(task, struct ldapsrv_service);
/* within the ntp_signd task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops\n"));
return;
/* run the rpc server as a single process to allow for shard
* handles, and sharing of ldb contexts */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
status = dcesrv_init_context(task->event_ctx,
NTSTATUS status;
const struct model_ops *model_ops;
- model_ops = process_model_startup(task->event_ctx, "standard");
+ model_ops = process_model_startup("standard");
if (model_ops == NULL) {
goto failed;
#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.
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;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
#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
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 *,
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);
/*
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);
}
/*
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);
}
/*
called when the process model is selected
*/
-static void single_model_init(struct tevent_context *ev)
+static void single_model_init(void)
{
}
/*
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);
/*
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;
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;
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;
torture_comment(tctx, "Listening for callbacks on %s\n", address);
- status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, &single_ops, address);
+ status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, process_model_startup("single"), address);
torture_assert_ntstatus_ok(tctx, status, "starting smb server");
status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints, &dce_ctx);
for (e=dce_ctx->endpoint_list;e;e=e->next) {
status = dcesrv_add_ep(dce_ctx, tctx->lp_ctx,
- e, tctx->ev, &single_ops);
+ e, tctx->ev, process_model_startup("single"));
torture_assert_ntstatus_ok(tctx, status,
"unable listen on dcerpc endpoint server");
}
task_server_set_title(task, "task[websrv]");
/* run the web server as a single process */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) goto failed;
if (lpcfg_interfaces(task->lp_ctx) && lpcfg_bind_interfaces_only(task->lp_ctx)) {
/* within the winbind task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
task_server_terminate(task,
"Can't find 'single' process model_ops", true);
/* within the wrepl task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(service->task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops"));
return NT_STATUS_INTERNAL_ERROR;
/* within the wrepl task we want to be a single process, so
ask for the single process model ops and pass these to the
stream_setup_socket() call. */
- model_ops = process_model_startup(task->event_ctx, "single");
+ model_ops = process_model_startup("single");
if (!model_ops) {
DEBUG(0,("Can't find 'single' process model_ops"));
return NT_STATUS_INTERNAL_ERROR;