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

metze at samba.org metze at samba.org
Sun Jul 30 17:50:37 GMT 2006


Author: metze
Date: 2006-07-30 17:50:37 +0000 (Sun, 30 Jul 2006)
New Revision: 17323

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

Log:
make better use of the composite api and fix the memory
hierachy

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	2006-07-30 17:45:11 UTC (rev 17322)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2006-07-30 17:50:37 UTC (rev 17323)
@@ -632,18 +632,10 @@
 	DATA_BLOB blob;
 	struct rpc_request *req;
 
-	/* we allocate a dcerpc_request so we can be in the same
-	   request queue as normal requests, but most of the request
-	   fields are not used as there is no call id */
-	req = talloc_zero(mem_ctx, struct rpc_request);
-	if (req == NULL) return NULL;
-
-	c = talloc_zero(mem_ctx, struct composite_context);
+	c = composite_create(mem_ctx,p->conn->event_ctx);
 	if (c == NULL) return NULL;
 
-	c->state = COMPOSITE_STATE_IN_PROGRESS;
 	c->private_data = p;
-	c->event_ctx = p->conn->event_ctx;
 
 	p->syntax = *syntax;
 	p->transfer_syntax = *transfer_syntax;
@@ -659,12 +651,8 @@
 	pkt.u.bind.max_recv_frag = 5840;
 	pkt.u.bind.assoc_group_id = 0;
 	pkt.u.bind.num_contexts = 1;
-	pkt.u.bind.ctx_list =
-		talloc_array(mem_ctx, struct dcerpc_ctx_list, 1);
-	if (pkt.u.bind.ctx_list == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
+	pkt.u.bind.ctx_list = talloc_array(mem_ctx, struct dcerpc_ctx_list, 1);
+	if (composite_nomem(pkt.u.bind.ctx_list, c)) return c;
 	pkt.u.bind.ctx_list[0].context_id = p->context_id;
 	pkt.u.bind.ctx_list[0].num_transfer_syntaxes = 1;
 	pkt.u.bind.ctx_list[0].abstract_syntax = p->syntax;
@@ -674,36 +662,34 @@
 	/* construct the NDR form of the packet */
 	c->status = ncacn_push_auth(&blob, c, &pkt,
 				    p->conn->security_state.auth_info);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	p->conn->transport.recv_data = dcerpc_recv_data;
 
+	/*
+	 * we allocate a dcerpc_request so we can be in the same
+	 * request queue as normal requests
+	 */
+	req = talloc_zero(c, struct rpc_request);
+	if (composite_nomem(req, c)) return c;
+
 	req->state = RPC_REQUEST_PENDING;
 	req->call_id = pkt.call_id;
 	req->async.private = c;
 	req->async.callback = dcerpc_composite_fail;
 	req->p = p;
 	req->recv_handler = dcerpc_bind_recv_handler;
-
 	DLIST_ADD_END(p->conn->pending, req, struct rpc_request *);
 
 	c->status = p->conn->transport.send_request(p->conn, &blob,
 						    True);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	event_add_timed(c->event_ctx, req,
 			timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0),
 			dcerpc_timeout_handler, req);
 
 	return c;
-
- failed:
-	composite_error(c, c->status);
-	return c;
 }
 
 /*
@@ -1559,18 +1545,10 @@
 	DATA_BLOB blob;
 	struct rpc_request *req;
 
-	/* we allocate a dcerpc_request so we can be in the same
-	   request queue as normal requests, but most of the request
-	   fields are not used as there is no call id */
-	req = talloc_zero(mem_ctx, struct rpc_request);
-	if (req == NULL) return NULL;
-
-	c = talloc_zero(req, struct composite_context);
+	c = composite_create(mem_ctx, p->conn->event_ctx);
 	if (c == NULL) return NULL;
 
-	c->state = COMPOSITE_STATE_IN_PROGRESS;
 	c->private_data = p;
-	c->event_ctx = p->conn->event_ctx;
 
 	p->syntax = *syntax;
 	p->transfer_syntax = *transfer_syntax;
@@ -1586,12 +1564,8 @@
 	pkt.u.alter.max_recv_frag = 5840;
 	pkt.u.alter.assoc_group_id = 0;
 	pkt.u.alter.num_contexts = 1;
-	pkt.u.alter.ctx_list = talloc_array(mem_ctx,
-						   struct dcerpc_ctx_list, 1);
-	if (pkt.u.alter.ctx_list == NULL) {
-		c->status = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
+	pkt.u.alter.ctx_list = talloc_array(c, struct dcerpc_ctx_list, 1);
+	if (composite_nomem(pkt.u.alter.ctx_list, c)) return c;
 	pkt.u.alter.ctx_list[0].context_id = p->context_id;
 	pkt.u.alter.ctx_list[0].num_transfer_syntaxes = 1;
 	pkt.u.alter.ctx_list[0].abstract_syntax = p->syntax;
@@ -1601,35 +1575,33 @@
 	/* construct the NDR form of the packet */
 	c->status = ncacn_push_auth(&blob, mem_ctx, &pkt,
 				    p->conn->security_state.auth_info);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	p->conn->transport.recv_data = dcerpc_recv_data;
 
+	/*
+	 * we allocate a dcerpc_request so we can be in the same
+	 * request queue as normal requests
+	 */
+	req = talloc_zero(c, struct rpc_request);
+	if (composite_nomem(req, c)) return c;
+
 	req->state = RPC_REQUEST_PENDING;
 	req->call_id = pkt.call_id;
 	req->async.private = c;
 	req->async.callback = dcerpc_composite_fail;
 	req->p = p;
 	req->recv_handler = dcerpc_alter_recv_handler;
-
 	DLIST_ADD_END(p->conn->pending, req, struct rpc_request *);
 
 	c->status = p->conn->transport.send_request(p->conn, &blob, True);
-	if (!NT_STATUS_IS_OK(c->status)) {
-		goto failed;
-	}
+	if (!composite_is_ok(c)) return c;
 
 	event_add_timed(c->event_ctx, req,
 			timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0),
 			dcerpc_timeout_handler, req);
 
 	return c;
-
- failed:
-	composite_error(c, c->status);
-	return c;
 }
 
 NTSTATUS dcerpc_alter_context_recv(struct composite_context *ctx)



More information about the samba-cvs mailing list