summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-07-30 17:50:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:15:14 -0500
commit46b2b8c890c7f61fe68325dcc180de471529bb53 (patch)
tree790fa8314a3906f8585785e46da5f245f800058c /source4/librpc/rpc
parent67fb28d9a802ffaf95e80703857a46d3b002c797 (diff)
downloadsamba-46b2b8c890c7f61fe68325dcc180de471529bb53.tar.gz
samba-46b2b8c890c7f61fe68325dcc180de471529bb53.tar.bz2
samba-46b2b8c890c7f61fe68325dcc180de471529bb53.zip
r17323: make better use of the composite api and fix the memory
hierachy metze (This used to be commit a0aa61a8d583ef626d082c47377c87008874e235)
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/dcerpc.c76
1 files changed, 24 insertions, 52 deletions
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 244ac9fdfa..b736826b63 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -632,18 +632,10 @@ struct composite_context *dcerpc_bind_send(struct dcerpc_pipe *p,
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 @@ struct composite_context *dcerpc_bind_send(struct dcerpc_pipe *p,
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 @@ struct composite_context *dcerpc_bind_send(struct dcerpc_pipe *p,
/* 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 @@ struct composite_context *dcerpc_alter_context_send(struct dcerpc_pipe *p,
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 @@ struct composite_context *dcerpc_alter_context_send(struct dcerpc_pipe *p,
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 @@ struct composite_context *dcerpc_alter_context_send(struct dcerpc_pipe *p,
/* 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)