From e55426fe7926ae6f8afe5fa6cfc009e0c3b54e38 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 22 Jun 2010 18:01:45 -0400 Subject: [PATCH] s3:rpc_client: let rpc_transport_tstream_init() create read and write queue metze --- source3/include/proto.h | 6 ++---- source3/rpc_client/rpc_transport_tstream.c | 23 +++++++++++++--------- source3/rpc_server/rpc_ncacn_np.c | 16 +-------------- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 0f02dfbecf6..9b41321df6c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4244,10 +4244,8 @@ NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd, /* The following definitions come from rpc_client/rpc_transport_tstream.c */ NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx, - struct tstream_context *npipe, - struct tevent_queue *read_queue, - struct tevent_queue *write_queue, - struct rpc_cli_transport **presult); + struct tstream_context **stream, + struct rpc_cli_transport **presult); /* The following definitions come from rpc_server/srv_eventlog_nt.c */ diff --git a/source3/rpc_client/rpc_transport_tstream.c b/source3/rpc_client/rpc_transport_tstream.c index c62540cb3f8..e05498b1a2f 100644 --- a/source3/rpc_client/rpc_transport_tstream.c +++ b/source3/rpc_client/rpc_transport_tstream.c @@ -316,17 +316,13 @@ static NTSTATUS rpc_tstream_write_recv(struct tevent_req *req, ssize_t *sent) * * @param mem_ctx - memory context used to allocate the transport * @param stream - a ready to use tstream -* @param read_queue - pre-createted tstream read queue -* @param write_queue - pre-createted tstream write queue * @param presult - the transport structure * * @return - a NT Status error code. */ NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx, - struct tstream_context *stream, - struct tevent_queue *read_queue, - struct tevent_queue *write_queue, - struct rpc_cli_transport **presult) + struct tstream_context **stream, + struct rpc_cli_transport **presult) { struct rpc_cli_transport *result; struct rpc_tstream_state *state; @@ -342,9 +338,18 @@ NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx, } result->priv = state; - state->stream = talloc_steal(state, stream); - state->read_queue = talloc_steal(state, read_queue); - state->write_queue = talloc_steal(state, write_queue); + state->read_queue = tevent_queue_create(state, "read_queue"); + if (state->read_queue == NULL) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + state->write_queue = tevent_queue_create(state, "write_queue"); + if (state->write_queue == NULL) { + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + + state->stream = talloc_move(state, stream); state->timeout = 10000; /* 10 seconds. */ result->trans_send = NULL; diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c index f4c47fc3e32..71ac69fe153 100644 --- a/source3/rpc_server/rpc_ncacn_np.c +++ b/source3/rpc_server/rpc_ncacn_np.c @@ -606,18 +606,6 @@ struct np_proxy_state *make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx, return NULL; } - result->read_queue = tevent_queue_create(result, "np_read"); - if (result->read_queue == NULL) { - DEBUG(0, ("tevent_queue_create failed\n")); - goto fail; - } - - result->write_queue = tevent_queue_create(result, "np_write"); - if (result->write_queue == NULL) { - DEBUG(0, ("tevent_queue_create failed\n")); - goto fail; - } - ev = s3_tevent_context_init(talloc_tos()); if (ev == NULL) { DEBUG(0, ("s3_tevent_context_init failed\n")); @@ -756,9 +744,7 @@ static NTSTATUS rpc_pipe_open_external(TALLOC_CTX *mem_ctx, result->max_recv_frag = RPC_MAX_PDU_FRAG_LEN; status = rpc_transport_tstream_init(result, - proxy_state->npipe, - proxy_state->read_queue, - proxy_state->write_queue, + &proxy_state->npipe, &result->transport); if (!NT_STATUS_IS_OK(status)) { goto done;