s3:smb2_server: simplify the talloc_pool handling for smbd_smb2_request
authorStefan Metzmacher <metze@samba.org>
Mon, 23 Jul 2012 16:22:59 +0000 (18:22 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 25 Jul 2012 10:15:01 +0000 (12:15 +0200)
metze

source3/smbd/globals.h
source3/smbd/smb2_server.c

index 4ca9e712dfb2ec014c6593dd23f1fc76d35e00d4..94098f028185b26487f903c7a09dd51d9acb1b34 100644 (file)
@@ -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 */
index 653a038da5e9d1811b23a054fb8d4b7bd941e434..979a179c1d3c3328ad93185957ddeff6a9bfffe5 100644 (file)
@@ -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;
 }