summaryrefslogtreecommitdiff
path: root/source4/smbd/service.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-09-26 03:05:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:16 -0500
commit764eddb69647681f784f343a122251ca1ecf62df (patch)
tree1d64246d07b4f040c4e36367e4172135c8af5011 /source4/smbd/service.c
parent4b1050a6cf3e6d9f7a8e75dd90ed1ccd52f29abb (diff)
downloadsamba-764eddb69647681f784f343a122251ca1ecf62df.tar.gz
samba-764eddb69647681f784f343a122251ca1ecf62df.tar.bz2
samba-764eddb69647681f784f343a122251ca1ecf62df.zip
r2646: - use a talloc destructor to ensure that sockets from the new socket
library are closed on abnormal termination - convert the service.h structures to the new talloc methods (This used to be commit 2dc334a3284858eb1c7190f9687c9b6c879ecc9d)
Diffstat (limited to 'source4/smbd/service.c')
-rw-r--r--source4/smbd/service.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/source4/smbd/service.c b/source4/smbd/service.c
index 0733e6fc0f..e3eb4a02c1 100644
--- a/source4/smbd/service.c
+++ b/source4/smbd/service.c
@@ -27,7 +27,6 @@ struct server_context *server_service_startup(const char *model)
{
int i;
const char **server_services = lp_server_services();
- TALLOC_CTX *mem_ctx;
struct server_context *srv_ctx;
const struct model_ops *model_ops;
@@ -42,20 +41,12 @@ struct server_context *server_service_startup(const char *model)
return NULL;
}
- mem_ctx = talloc_init("server_context");
- if (!mem_ctx) {
- DEBUG(0,("talloc_init(server_context) failed\n"));
- return NULL;
- }
-
- srv_ctx = talloc_p(mem_ctx, struct server_context);
+ srv_ctx = talloc_p(NULL, struct server_context);
if (!srv_ctx) {
- DEBUG(0,("talloc_p(mem_ctx, struct server_context) failed\n"));
return NULL;
}
ZERO_STRUCTP(srv_ctx);
- srv_ctx->mem_ctx = mem_ctx;
srv_ctx->events = event_context_init();
if (!srv_ctx->events) {
@@ -65,7 +56,6 @@ struct server_context *server_service_startup(const char *model)
for (i=0;server_services[i];i++) {
- TALLOC_CTX *mem_ctx2;
const struct server_service_ops *service_ops;
struct server_service *service;
@@ -75,16 +65,12 @@ struct server_context *server_service_startup(const char *model)
return NULL;
}
- mem_ctx2 = talloc_init("server_service");
-
- service = talloc_p(mem_ctx2, struct server_service);
+ service = talloc_p(srv_ctx, struct server_service);
if (!service) {
- DEBUG(0,("talloc_p(mem_ctx, struct server_service) failed\n"));
return NULL;
}
ZERO_STRUCTP(service);
- service->mem_ctx = mem_ctx2;
service->ops = service_ops;
service->model_ops = model_ops;
service->srv_ctx = srv_ctx;
@@ -129,6 +115,8 @@ struct server_socket *service_setup_socket(struct server_service *service,
return NULL;
}
+ talloc_steal(service, socket_ctx);
+
/* ready to listen */
status = socket_set_option(socket_ctx, "SO_KEEPALIVE SO_REUSEADDR=1", NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -169,7 +157,6 @@ struct server_socket *service_setup_socket(struct server_service *service,
fde.handler = model_ops->accept_connection;
ZERO_STRUCTP(srv_sock);
- srv_sock->mem_ctx = srv_sock;
srv_sock->service = service;
srv_sock->socket = socket_ctx;
srv_sock->event.ctx = service->srv_ctx->events;
@@ -201,7 +188,6 @@ struct server_connection *server_setup_connection(struct event_context *ev,
}
ZERO_STRUCTP(srv_conn);
- srv_conn->mem_ctx = srv_conn;
fde.private = srv_conn;
fde.fd = socket_get_fd(sock);
@@ -255,7 +241,7 @@ void server_destroy_connection(struct server_connection *srv_conn)
event_remove_timed(srv_conn->event.ctx, srv_conn->event.idle);
srv_conn->event.idle = NULL;
- talloc_destroy(srv_conn->mem_ctx);
+ talloc_free(srv_conn);
}
void server_io_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags)