summaryrefslogtreecommitdiff
path: root/source4/smbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-15 10:12:22 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-15 10:19:34 +1100
commitef7f4a142068757dcf0dc11c5b7cf03755be45a8 (patch)
treed8e56b44df249b52da8d913f92293ac39d45be35 /source4/smbd
parentec590fc9e37c38891bdd10aaae5bac46f5e71f75 (diff)
downloadsamba-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/smbd')
-rw-r--r--source4/smbd/service_named_pipe.c8
-rw-r--r--source4/smbd/service_stream.c5
2 files changed, 8 insertions, 5 deletions
diff --git a/source4/smbd/service_named_pipe.c b/source4/smbd/service_named_pipe.c
index f420e2bacb..25d37af8c4 100644
--- a/source4/smbd/service_named_pipe.c
+++ b/source4/smbd/service_named_pipe.c
@@ -289,7 +289,8 @@ static const struct stream_server_ops named_pipe_stream_ops = {
.send_handler = named_pipe_send,
};
-NTSTATUS tstream_setup_named_pipe(struct tevent_context *event_context,
+NTSTATUS tstream_setup_named_pipe(TALLOC_CTX *mem_ctx,
+ struct tevent_context *event_context,
struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
const struct stream_server_ops *stream_ops,
@@ -300,7 +301,7 @@ NTSTATUS tstream_setup_named_pipe(struct tevent_context *event_context,
struct named_pipe_socket *pipe_sock;
NTSTATUS status = NT_STATUS_NO_MEMORY;;
- pipe_sock = talloc(event_context, struct named_pipe_socket);
+ pipe_sock = talloc(mem_ctx, struct named_pipe_socket);
if (pipe_sock == NULL) {
goto fail;
}
@@ -338,7 +339,8 @@ NTSTATUS tstream_setup_named_pipe(struct tevent_context *event_context,
pipe_sock->ops = stream_ops;
pipe_sock->private_data = private_data;
- status = stream_setup_socket(event_context,
+ status = stream_setup_socket(pipe_sock,
+ event_context,
lp_ctx,
model_ops,
&named_pipe_stream_ops,
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 85efa34339..916393253b 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -255,7 +255,8 @@ static void stream_accept_handler(struct tevent_context *ev, struct tevent_fd *f
a string for the port. Should leave allocating a port nr
to the socket implementation - JRV20070903
*/
-NTSTATUS stream_setup_socket(struct tevent_context *event_context,
+NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
+ struct tevent_context *event_context,
struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
const struct stream_server_ops *stream_ops,
@@ -271,7 +272,7 @@ NTSTATUS stream_setup_socket(struct tevent_context *event_context,
struct tevent_fd *fde;
int i;
- stream_socket = talloc_zero(event_context, struct stream_socket);
+ stream_socket = talloc_zero(mem_ctx, struct stream_socket);
NT_STATUS_HAVE_NO_MEMORY(stream_socket);
status = socket_create(family, SOCKET_TYPE_STREAM, &stream_socket->sock, 0);