From 759a04e58a88b400dbf0cafc2b86ab58ea196433 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Jul 2011 09:53:10 -0400 Subject: s3-rpc_server: Move pipe/handles functions Put InternalPipes related functions in rpc_handles.c and out of rpc_ncacn_np.c rpc_handles.c is the only file that really uses them after all and ncacn_np.c is the wrong place for that stuff. While ther remove unnecessary wrapper functions now that the InternalPipes static variable is directly accessible. Also move all pipes_struct related header stuff in its own rpc_pipes.h header. Signed-off-by: Andreas Schneider --- source3/rpc_server/rpc_handles.c | 70 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'source3/rpc_server/rpc_handles.c') diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c index 3500a228d5..1fbee9e3c0 100644 --- a/source3/rpc_server/rpc_handles.c +++ b/source3/rpc_server/rpc_handles.c @@ -23,13 +23,75 @@ #include "../librpc/gen_ndr/ndr_lsa.h" #include "../librpc/gen_ndr/ndr_samr.h" #include "auth.h" -#include "ntdomain.h" -#include "rpc_server/rpc_ncacn_np.h" +#include "rpc_server/rpc_pipes.h" #include "../libcli/security/security.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV +static struct pipes_struct *InternalPipes; + +/* TODO + * the following prototypes are declared here to avoid + * code being moved about too much for a patch to be + * disrupted / less obvious. + * + * these functions, and associated functions that they + * call, should be moved behind a .so module-loading + * system _anyway_. so that's the next step... + */ + +bool check_open_pipes(void) +{ + struct pipes_struct *p; + + for (p = InternalPipes; p != NULL; p = p->next) { + if (num_pipe_handles(p) != 0) { + return true; + } + } + return false; +} + +/**************************************************************************** + Close an rpc pipe. +****************************************************************************/ + +static void free_pipe_rpc_context_internal(struct pipe_rpc_fns *list) +{ + struct pipe_rpc_fns *tmp = list; + struct pipe_rpc_fns *tmp2; + + while (tmp) { + tmp2 = tmp->next; + SAFE_FREE(tmp); + tmp = tmp2; + } + + return; +} + +int close_internal_rpc_pipe_hnd(struct pipes_struct *p) +{ + if (!p) { + DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n")); + return False; + } + + TALLOC_FREE(p->auth.auth_ctx); + + /* Free the handles database. */ + close_policy_by_pipe(p); + + free_pipe_rpc_context_internal( p->contexts ); + + DLIST_REMOVE(InternalPipes, p); + + ZERO_STRUCTP(p); + + return 0; +} + /* * Handle database - stored per pipe. */ @@ -82,9 +144,7 @@ bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *synta struct pipes_struct *plist; struct handle_list *hl; - for (plist = get_first_internal_pipe(); - plist; - plist = get_next_internal_pipe(plist)) { + for (plist = InternalPipes; plist; plist = plist->next) { struct pipe_rpc_fns *p_ctx; bool stop = false; -- cgit