From 5da783f4a79ee0a927f2483ae20b691074bb3007 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 7 Jun 2010 14:08:05 -0400 Subject: s3:smbd add utility function to check if there are open pipes --- source3/include/proto.h | 1 + source3/rpc_server/rpc_ncacn_np_internal.c | 12 ++++++++++++ source3/smbd/conn.c | 11 +++-------- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 3d25688cf3..2f68f0efc6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5208,6 +5208,7 @@ bool api_pipe_request(pipes_struct *p); pipes_struct *get_first_internal_pipe(void); pipes_struct *get_next_internal_pipe(pipes_struct *p); +bool check_open_pipes(void); bool fsp_is_np(struct files_struct *fsp); struct tsocket_address; diff --git a/source3/rpc_server/rpc_ncacn_np_internal.c b/source3/rpc_server/rpc_ncacn_np_internal.c index f5a3737844..18251c688e 100644 --- a/source3/rpc_server/rpc_ncacn_np_internal.c +++ b/source3/rpc_server/rpc_ncacn_np_internal.c @@ -68,6 +68,18 @@ static void free_pipe_rpc_context_internal( PIPE_RPC_FNS *list ) return; } +bool check_open_pipes(void) +{ + 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. ****************************************************************************/ diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c index afb7a7fa85..707f6c4aa1 100644 --- a/source3/smbd/conn.c +++ b/source3/smbd/conn.c @@ -213,7 +213,6 @@ bool conn_close_all(struct smbd_server_connection *sconn) bool conn_idle_all(struct smbd_server_connection *sconn,time_t t) { int deadtime = lp_deadtime()*60; - pipes_struct *plist = NULL; connection_struct *conn; if (deadtime <= 0) @@ -243,14 +242,10 @@ bool conn_idle_all(struct smbd_server_connection *sconn,time_t t) * Check all pipes for any open handles. We cannot * idle with a handle open. */ - - for (plist = get_first_internal_pipe(); plist; - plist = get_next_internal_pipe(plist)) { - if (num_pipe_handles(plist->pipe_handles) != 0) { - return False; - } + if (check_open_pipes()) { + return False; } - + return True; } -- cgit