summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-07-23 18:22:59 +0200
committerStefan Metzmacher <metze@samba.org>2012-07-25 12:15:01 +0200
commitc66a45d3f29570a907ef1f9a3e499eb19e804e7e (patch)
tree097e8e2dcd8f30e7c839af5f16f120ef799606cf /source3/smbd
parentd58aa46c08f69b1b048375b0eea85bdf25f99cda (diff)
downloadsamba-c66a45d3f29570a907ef1f9a3e499eb19e804e7e.tar.gz
samba-c66a45d3f29570a907ef1f9a3e499eb19e804e7e.tar.bz2
samba-c66a45d3f29570a907ef1f9a3e499eb19e804e7e.zip
s3:smb2_server: simplify the talloc_pool handling for smbd_smb2_request
metze
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/globals.h3
-rw-r--r--source3/smbd/smb2_server.c40
2 files changed, 4 insertions, 39 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 4ca9e712df..94098f0281 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -444,9 +444,6 @@ NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn,
struct smbd_smb2_request {
struct smbd_smb2_request *prev, *next;
- TALLOC_CTX *mem_pool;
- struct smbd_smb2_request **parent;
-
struct smbd_server_connection *sconn;
/* the session the request operates on, maybe NULL */
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 653a038da5..979a179c1d 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -151,30 +151,9 @@ static void smb2_setup_nbt_length(struct iovec *vector, int count)
_smb2_setlen(vector[0].iov_base, len);
}
-static int smbd_smb2_request_parent_destructor(struct smbd_smb2_request **req)
-{
- if (*req) {
- (*req)->parent = NULL;
- (*req)->mem_pool = NULL;
- }
-
- return 0;
-}
-
-static int smbd_smb2_request_destructor(struct smbd_smb2_request *req)
-{
- if (req->parent) {
- *req->parent = NULL;
- talloc_free(req->mem_pool);
- }
-
- return 0;
-}
-
static struct smbd_smb2_request *smbd_smb2_request_allocate(TALLOC_CTX *mem_ctx)
{
TALLOC_CTX *mem_pool;
- struct smbd_smb2_request **parent;
struct smbd_smb2_request *req;
#if 0
@@ -187,27 +166,17 @@ static struct smbd_smb2_request *smbd_smb2_request_allocate(TALLOC_CTX *mem_ctx)
return NULL;
}
- parent = talloc(mem_pool, struct smbd_smb2_request *);
- if (parent == NULL) {
- talloc_free(mem_pool);
- return NULL;
- }
-
- req = talloc_zero(parent, struct smbd_smb2_request);
+ req = talloc_zero(mem_pool, struct smbd_smb2_request);
if (req == NULL) {
talloc_free(mem_pool);
return NULL;
}
- *parent = req;
- req->mem_pool = mem_pool;
- req->parent = parent;
+ talloc_reparent(mem_pool, mem_ctx, req);
+ TALLOC_FREE(mem_pool);
req->last_session_id = UINT64_MAX;
req->last_tid = UINT32_MAX;
- talloc_set_destructor(parent, smbd_smb2_request_parent_destructor);
- talloc_set_destructor(req, smbd_smb2_request_destructor);
-
return req;
}
@@ -2800,8 +2769,7 @@ static NTSTATUS smbd_smb2_request_read_recv(struct tevent_req *req,
return status;
}
- talloc_steal(mem_ctx, state->smb2_req->mem_pool);
- *_smb2_req = state->smb2_req;
+ *_smb2_req = talloc_move(mem_ctx, &state->smb2_req);
tevent_req_received(req);
return NT_STATUS_OK;
}