diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2017-09-15 07:09:23 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2017-10-19 05:33:09 +0200 |
commit | b852ad044b98c0c574c3420956e153055d46136d (patch) | |
tree | 4246355fbade866ba399d3e6266b7572df953b09 /source4/smb_server | |
parent | 6d7a8d80cdc9ee996ff503d8834037001cf233d9 (diff) | |
download | samba-b852ad044b98c0c574c3420956e153055d46136d.tar.gz |
source4/smbd: refactor the process model for prefork
Refactor the process model code to allow the addition of a prefork
process model.
- Add a process context to contain process model specific state
- Add a service details structure to allow service to indicate which
process model options they can support.
In the new code the services advertise the features they support to the
process model. The process model context is plumbed through to allow the
process model to keep track of the supported options, and any state
the process model may require.
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/smb_server')
-rw-r--r-- | source4/smb_server/service_smb.c | 18 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 5 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 3 |
3 files changed, 20 insertions, 6 deletions
diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index a607861d6e3..ddf24a994a8 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -60,7 +60,11 @@ static void smbsrv_task_init(struct task_server *task) */ for(i = 0; i < num_interfaces; i++) { const char *address = iface_list_n_ip(ifaces, i); - status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, address); + status = smbsrv_add_socket(task, task->event_ctx, + task->lp_ctx, + task->model_ops, + address, + task->process_context); if (!NT_STATUS_IS_OK(status)) goto failed; } } else { @@ -72,7 +76,11 @@ static void smbsrv_task_init(struct task_server *task) goto failed; } for (i=0; wcard[i]; i++) { - status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, wcard[i]); + status = smbsrv_add_socket(task, task->event_ctx, + task->lp_ctx, + task->model_ops, + wcard[i], + task->process_context); if (!NT_STATUS_IS_OK(status)) goto failed; } talloc_free(wcard); @@ -87,7 +95,11 @@ failed: /* called at smbd startup - register ourselves as a server service */ NTSTATUS server_service_smb_init(TALLOC_CTX *ctx) { + struct service_details details = { + .inhibit_fork_on_accept = true, + .inhibit_pre_fork = true + }; ntvfs_init(cmdline_lp_ctx); share_init(); - return register_server_service(ctx, "smb", smbsrv_task_init); + return register_server_service(ctx, "smb", smbsrv_task_init, &details); } diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index 7e4c032ab4c..45641a4f2c9 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -179,7 +179,8 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx, struct tevent_context *event_context, struct loadparm_context *lp_ctx, const struct model_ops *model_ops, - const char *address) + const char *address, + void *process_context) { const char **ports = lpcfg_smb_ports(lp_ctx); int i; @@ -192,7 +193,7 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx, model_ops, &smb_stream_ops, "ip", address, &port, lpcfg_socket_options(lp_ctx), - NULL); + NULL, process_context); NT_STATUS_NOT_OK_RETURN(status); } diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 40af4a64bb3..5ddfe78a288 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -397,7 +397,8 @@ NTSTATUS smbsrv_add_socket(TALLOC_CTX *mem_ctx, struct tevent_context *event_context, struct loadparm_context *lp_ctx, const struct model_ops *model_ops, - const char *address); + const char *address, + void *process_context); struct loadparm_context; |