diff options
author | Simo Sorce <idra@samba.org> | 2011-07-21 11:02:59 -0400 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-07-21 19:50:02 +0200 |
commit | 156a0ffe542339952a6e2db191ffc586227edd5a (patch) | |
tree | 84d6b14cb96e7b0ed9c4311df175e01ef0115f70 /source3/rpc_server/rpc_ncacn_np.c | |
parent | 759a04e58a88b400dbf0cafc2b86ab58ea196433 (diff) | |
download | samba-156a0ffe542339952a6e2db191ffc586227edd5a.tar.gz samba-156a0ffe542339952a6e2db191ffc586227edd5a.tar.bz2 samba-156a0ffe542339952a6e2db191ffc586227edd5a.zip |
s3-rpc_server: Create common function to allocate pipes_struct
Avoid code duplication and fix bug where a new pipe was not added to
InternalPipes upon creation in make_server_pipes_struct()
Signed-off-by: Andreas Schneider <asn@samba.org>
Autobuild-User: Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date: Thu Jul 21 19:50:02 CEST 2011 on sn-devel-104
Diffstat (limited to 'source3/rpc_server/rpc_ncacn_np.c')
-rw-r--r-- | source3/rpc_server/rpc_ncacn_np.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/source3/rpc_server/rpc_ncacn_np.c b/source3/rpc_server/rpc_ncacn_np.c index dea079f3f5..2ed4a01704 100644 --- a/source3/rpc_server/rpc_ncacn_np.c +++ b/source3/rpc_server/rpc_ncacn_np.c @@ -31,7 +31,7 @@ #include "librpc/gen_ndr/auth.h" #include "../auth/auth_sam_reply.h" #include "auth.h" -#include "ntdomain.h" +#include "rpc_server/rpc_pipes.h" #include "../lib/tsocket/tsocket.h" #include "../lib/util/tevent_ntstatus.h" #include "rpc_contexts.h" @@ -51,26 +51,21 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, { struct pipes_struct *p; struct pipe_rpc_fns *context_fns; + const char *pipe_name; + int ret; - DEBUG(4,("Create pipe requested %s\n", - get_pipe_name_from_syntax(talloc_tos(), syntax))); + pipe_name = get_pipe_name_from_syntax(talloc_tos(), syntax); - p = talloc_zero(mem_ctx, struct pipes_struct); + DEBUG(4,("Create pipe requested %s\n", pipe_name)); - if (!p) { + ret = make_base_pipes_struct(mem_ctx, msg_ctx, pipe_name, + NCALRPC, RPC_LITTLE_ENDIAN, false, + remote_address, NULL, &p); + if (ret) { DEBUG(0,("ERROR! no memory for pipes_struct!\n")); return NULL; } - p->mem_ctx = talloc_named(p, 0, "pipe %s %p", - get_pipe_name_from_syntax(talloc_tos(), - syntax), p); - if (p->mem_ctx == NULL) { - DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n")); - TALLOC_FREE(p); - return NULL; - } - if (!init_pipe_handles(p, syntax)) { DEBUG(0,("open_rpc_pipe_p: init_pipe_handles failed.\n")); TALLOC_FREE(p); @@ -85,19 +80,6 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, return NULL; } - p->msg_ctx = msg_ctx; - - DLIST_ADD(InternalPipes, p); - - p->remote_address = tsocket_address_copy(remote_address, p); - if (p->remote_address == NULL) { - return false; - } - - p->endian = RPC_LITTLE_ENDIAN; - - p->transport = NCALRPC; - context_fns = SMB_MALLOC_P(struct pipe_rpc_fns); if (context_fns == NULL) { DEBUG(0,("malloc() failed!\n")); @@ -113,10 +95,7 @@ struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx, /* add to the list of open contexts */ DLIST_ADD(p->contexts, context_fns); - DEBUG(4,("Created internal pipe %s\n", - get_pipe_name_from_syntax(talloc_tos(), syntax))); - - talloc_set_destructor(p, close_internal_rpc_pipe_hnd); + DEBUG(4,("Created internal pipe %s\n", pipe_name)); return p; } |