mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
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>
This commit is contained in:
parent
3a78148269
commit
046d38faa5
@ -550,7 +550,7 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns, struct loadparm_c
|
||||
/* 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;
|
||||
|
@ -537,7 +537,7 @@ static NTSTATUS kdc_startup_interfaces(struct kdc_server *kdc, struct loadparm_c
|
||||
/* 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;
|
||||
|
@ -899,7 +899,7 @@ static void ldapsrv_task_init(struct task_server *task)
|
||||
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);
|
||||
|
@ -503,7 +503,7 @@ static void ntp_signd_task_init(struct task_server *task)
|
||||
/* 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;
|
||||
|
@ -56,7 +56,7 @@ static void dcesrv_task_init(struct task_server *task)
|
||||
|
||||
/* 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,
|
||||
|
@ -119,7 +119,7 @@ static void samba3_smb_task_init(struct task_server *task)
|
||||
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;
|
||||
|
@ -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.
|
||||
|
||||
@ -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;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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -460,7 +460,7 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
|
||||
|
||||
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);
|
||||
@ -469,7 +469,7 @@ static bool test_start_dcerpc_server(struct torture_context *tctx,
|
||||
|
||||
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");
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ static void websrv_task_init(struct task_server *task)
|
||||
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)) {
|
||||
|
@ -205,7 +205,7 @@ static void winbind_task_init(struct task_server *task)
|
||||
/* 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);
|
||||
|
@ -357,7 +357,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
|
||||
/* 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;
|
||||
@ -430,7 +430,7 @@ NTSTATUS wreplsrv_setup_sockets(struct wreplsrv_service *service, struct loadpar
|
||||
/* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user