svn commit: samba r5488 - in branches/SAMBA_4_0/source/librpc/rpc: .

metze at samba.org metze at samba.org
Mon Feb 21 13:48:11 GMT 2005


Author: metze
Date: 2005-02-21 13:48:11 +0000 (Mon, 21 Feb 2005)
New Revision: 5488

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5488

Log:
- let the request be a child of the pipe struct

  to fix dcerpc_pipe_close() on a secondary connection,
  while the callers mem_ctx of a request is still valid
 
- fix up some memory contexts

TODO: split up output mem_ctx from ndr_pull context

metze

Modified:
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2005-02-21 13:13:21 UTC (rev 5487)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2005-02-21 13:48:11 UTC (rev 5488)
@@ -854,7 +854,6 @@
 struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p, 
 					const struct GUID *object,
 					uint16_t opnum,
-					TALLOC_CTX *mem_ctx,
 					DATA_BLOB *stub_data)
 {
 	struct rpc_request *req;
@@ -865,7 +864,7 @@
 
 	p->conn->transport.recv_data = dcerpc_request_recv_data;
 
-	req = talloc(mem_ctx, struct rpc_request);
+	req = talloc(p, struct rpc_request);
 	if (req == NULL) {
 		return NULL;
 	}
@@ -923,7 +922,7 @@
 			(stub_data->length - remaining);
 		pkt.u.request.stub_and_verifier.length = chunk;
 
-		req->status = dcerpc_push_request_sign(p->conn, &blob, mem_ctx, &pkt);
+		req->status = dcerpc_push_request_sign(p->conn, &blob, req, &pkt);
 		if (!NT_STATUS_IS_OK(req->status)) {
 			req->state = RPC_REQUEST_DONE;
 			DLIST_REMOVE(p->conn->pending, req);
@@ -995,7 +994,7 @@
 {
 	struct rpc_request *req;
 
-	req = dcerpc_request_send(p, object, opnum, mem_ctx, stub_data_in);
+	req = dcerpc_request_send(p, object, opnum, stub_data_in);
 	if (req == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
@@ -1167,7 +1166,7 @@
 	call = &table->calls[opnum];
 
 	/* setup for a ndr_push_* call */
-	push = ndr_push_init();
+	push = ndr_push_init_ctx(mem_ctx);
 	if (!push) {
 		return NULL;
 	}
@@ -1181,7 +1180,7 @@
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(2,("Unable to ndr_push structure in dcerpc_ndr_request_send - %s\n",
 			 nt_errstr(status)));
-		ndr_push_free(push);
+		talloc_free(push);
 		return NULL;
 	}
 
@@ -1189,12 +1188,12 @@
 	request = ndr_push_blob(push);
 
 	if (p->conn->flags & DCERPC_DEBUG_VALIDATE_IN) {
-		status = dcerpc_ndr_validate_in(p->conn, mem_ctx, request, call->struct_size, 
+		status = dcerpc_ndr_validate_in(p->conn, push, request, call->struct_size, 
 						call->ndr_push, call->ndr_pull);
 		if (!NT_STATUS_IS_OK(status)) {
 			DEBUG(2,("Validation failed in dcerpc_ndr_request_send - %s\n",
 				 nt_errstr(status)));
-			ndr_push_free(push);
+			talloc_free(push);
 			return NULL;
 		}
 	}
@@ -1203,7 +1202,7 @@
 	dump_data(10, request.data, request.length);
 
 	/* make the actual dcerpc request */
-	req = dcerpc_request_send(p, object, opnum, mem_ctx, &request);
+	req = dcerpc_request_send(p, object, opnum, &request);
 
 	if (req != NULL) {
 		req->ndr.table = table;
@@ -1212,8 +1211,8 @@
 		req->ndr.mem_ctx = mem_ctx;
 	}
 
-	ndr_push_free(push);
-	
+	talloc_free(push);
+
 	return req;
 }
 
@@ -1243,14 +1242,19 @@
 	}
 
 	flags = req->flags;
-	talloc_free(req);
 
 	/* prepare for ndr_pull_* */
 	pull = ndr_pull_init_flags(p->conn, &response, mem_ctx);
 	if (!pull) {
+		talloc_free(req);
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	if (pull->data) {
+		pull->data = talloc_steal(pull, pull->data);
+	}
+	talloc_free(req);
+
 	if (flags & DCERPC_PULL_BIGENDIAN) {
 		pull->flags |= LIBNDR_FLAG_BIGENDIAN;
 	}
@@ -1267,7 +1271,7 @@
 	}
 
 	if (p->conn->flags & DCERPC_DEBUG_VALIDATE_OUT) {
-		status = dcerpc_ndr_validate_out(p->conn, mem_ctx, r, call->struct_size, 
+		status = dcerpc_ndr_validate_out(p->conn, pull, r, call->struct_size, 
 						 call->ndr_push, call->ndr_pull);
 		if (!NT_STATUS_IS_OK(status)) {
 			dcerpc_log_packet(table, opnum, NDR_OUT, 
@@ -1286,6 +1290,8 @@
 		   those versions then we need to ignore this error */
 	}
 
+	/* TODO: make pull context independent from the output mem_ctx and free the pull context */
+
 	return NT_STATUS_OK;
 }
 



More information about the samba-cvs mailing list