diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-11-15 10:12:22 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-11-15 10:19:34 +1100 |
commit | ef7f4a142068757dcf0dc11c5b7cf03755be45a8 (patch) | |
tree | d8e56b44df249b52da8d913f92293ac39d45be35 /source4/smb_server | |
parent | ec590fc9e37c38891bdd10aaae5bac46f5e71f75 (diff) | |
download | samba-ef7f4a142068757dcf0dc11c5b7cf03755be45a8.tar.gz samba-ef7f4a142068757dcf0dc11c5b7cf03755be45a8.tar.bz2 samba-ef7f4a142068757dcf0dc11c5b7cf03755be45a8.zip |
s4-server: make server sockets a child of the task context
We previously allocated sockets as direct children of the event
context. That led to crashes if a service called
task_server_terminate(), as it left the socket open and handling
events for a dead protocol.
Making them a child of the task allows the task to terminate and take
all its sockets with it.
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/smb_server')
-rw-r--r-- | source4/smb_server/service_smb.c | 4 | ||||
-rw-r--r-- | source4/smb_server/smb_samba3.c | 11 | ||||
-rw-r--r-- | source4/smb_server/smb_server.c | 9 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 7 |
4 files changed, 18 insertions, 13 deletions
diff --git a/source4/smb_server/service_smb.c b/source4/smb_server/service_smb.c index 54feccbe05..583360bbe7 100644 --- a/source4/smb_server/service_smb.c +++ b/source4/smb_server/service_smb.c @@ -58,12 +58,12 @@ static void smbsrv_task_init(struct task_server *task) */ for(i = 0; i < num_interfaces; i++) { const char *address = iface_n_ip(ifaces, i); - status = smbsrv_add_socket(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); if (!NT_STATUS_IS_OK(status)) goto failed; } } else { /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */ - status = smbsrv_add_socket(task->event_ctx, task->lp_ctx, task->model_ops, + status = smbsrv_add_socket(task, task->event_ctx, task->lp_ctx, task->model_ops, lpcfg_socket_address(task->lp_ctx)); if (!NT_STATUS_IS_OK(status)) goto failed; } diff --git a/source4/smb_server/smb_samba3.c b/source4/smb_server/smb_samba3.c index ee12480c39..ed9027afac 100644 --- a/source4/smb_server/smb_samba3.c +++ b/source4/smb_server/smb_samba3.c @@ -86,7 +86,8 @@ static const struct stream_server_ops samba3_smb_stream_ops = { /* setup a listening socket on all the SMB ports for a particular address */ -static NTSTATUS samba3_add_socket(struct tevent_context *event_context, +static NTSTATUS samba3_add_socket(struct task_server *task, + struct tevent_context *event_context, struct loadparm_context *lp_ctx, const struct model_ops *model_ops, const char *address) @@ -98,7 +99,7 @@ static NTSTATUS samba3_add_socket(struct tevent_context *event_context, for (i=0;ports[i];i++) { uint16_t port = atoi(ports[i]); if (port == 0) continue; - status = stream_setup_socket(event_context, lp_ctx, + status = stream_setup_socket(task, event_context, lp_ctx, model_ops, &samba3_smb_stream_ops, "ip", address, &port, lpcfg_socket_options(lp_ctx), @@ -142,14 +143,16 @@ static void samba3_smb_task_init(struct task_server *task) */ for(i = 0; i < num_interfaces; i++) { const char *address = iface_n_ip(ifaces, i); - status = samba3_add_socket(task->event_ctx, + status = samba3_add_socket(task, + task->event_ctx, task->lp_ctx, model_ops, address); if (!NT_STATUS_IS_OK(status)) goto failed; } } else { /* Just bind to lpcfg_socket_address() (usually 0.0.0.0) */ - status = samba3_add_socket(task->event_ctx, task->lp_ctx, + status = samba3_add_socket(task, + task->event_ctx, task->lp_ctx, model_ops, lpcfg_socket_address(task->lp_ctx)); if (!NT_STATUS_IS_OK(status)) goto failed; diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c index 8e54423706..d21e5fbdb0 100644 --- a/source4/smb_server/smb_server.c +++ b/source4/smb_server/smb_server.c @@ -175,10 +175,11 @@ static const struct stream_server_ops smb_stream_ops = { /* setup a listening socket on all the SMB ports for a particular address */ -_PUBLIC_ NTSTATUS smbsrv_add_socket(struct tevent_context *event_context, +_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 struct model_ops *model_ops, + const char *address) { const char **ports = lpcfg_smb_ports(lp_ctx); int i; @@ -187,7 +188,7 @@ _PUBLIC_ NTSTATUS smbsrv_add_socket(struct tevent_context *event_context, for (i=0;ports[i];i++) { uint16_t port = atoi(ports[i]); if (port == 0) continue; - status = stream_setup_socket(event_context, lp_ctx, + status = stream_setup_socket(mem_ctx, event_context, lp_ctx, model_ops, &smb_stream_ops, "ipv4", address, &port, lpcfg_socket_options(lp_ctx), diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index 4399dc8c70..6088853743 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -395,10 +395,11 @@ struct smbsrv_connection { struct model_ops; struct loadparm_context; -NTSTATUS smbsrv_add_socket(struct tevent_context *event_context, +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 struct model_ops *model_ops, + const char *address); struct loadparm_context; |