Refactoring: Make close_internal_rpc_pipe_hnd a talloc destructor
authorVolker Lendecke <vl@samba.org>
Sat, 12 Jul 2008 10:25:42 +0000 (12:25 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 26 Jul 2008 11:20:10 +0000 (13:20 +0200)
(This used to be commit 10b47a0c2cfd62489428518112da82f73a52b7bc)

source3/include/ntdomain.h
source3/rpc_server/srv_pipe_hnd.c

index 484f173afed9c31a62158283068f67b0b908efc3..da3dd14189391dcb2a40480b6ebe6fd35ab0a1b2 100644 (file)
@@ -344,15 +344,6 @@ typedef struct smb_np_struct {
                                   char *data, size_t max_len,
                                   bool *pipe_outstanding);
 
                                   char *data, size_t max_len,
                                   bool *pipe_outstanding);
 
-       /* call to close a namedpipe.
-        * function is expected to perform all cleanups
-        * necessary, free all memory etc.
-        *
-        * returns True if cleanup was successful (not that
-        * we particularly care).
-        */
-       bool     (*namedpipe_close)(void * np_state);
-
 } smb_np_struct;
 
 struct api_struct {  
 } smb_np_struct;
 
 struct api_struct {  
index aa5bd5394a17896a4bc8f0e48faa3529f843998d..2e77b5b90330468bb0bf1b73c1faa17dce7fd206 100644 (file)
@@ -64,7 +64,7 @@ static struct bitmap *bmap;
 static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n,
                bool *is_data_outstanding);
 static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n);
 static ssize_t read_from_internal_pipe(void *np_conn, char *data, size_t n,
                bool *is_data_outstanding);
 static ssize_t write_to_internal_pipe(void *np_conn, char *data, size_t n);
-static bool close_internal_rpc_pipe_hnd(void *np_conn);
+static int close_internal_rpc_pipe_hnd(struct pipes_struct *pipe);
 
 /****************************************************************************
  Internal Pipe iterator functions.
 
 /****************************************************************************
  Internal Pipe iterator functions.
@@ -213,7 +213,6 @@ smb_np_struct *open_rpc_pipe_p(const char *pipe_name,
        p->namedpipe_create = make_internal_rpc_pipe_p;
        p->namedpipe_read = read_from_internal_pipe;
        p->namedpipe_write = write_to_internal_pipe;
        p->namedpipe_create = make_internal_rpc_pipe_p;
        p->namedpipe_read = read_from_internal_pipe;
        p->namedpipe_write = write_to_internal_pipe;
-       p->namedpipe_close = close_internal_rpc_pipe_hnd;
 
        p->np_state = p->namedpipe_create(pipe_name, conn->client_address,
                                          conn->server_info, vuid);
 
        p->np_state = p->namedpipe_create(pipe_name, conn->client_address,
                                          conn->server_info, vuid);
@@ -341,6 +340,8 @@ struct pipes_struct *make_internal_rpc_pipe_p(const char *pipe_name,
        DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n",
                 pipe_name, pipes_open));
 
        DEBUG(4,("Created internal pipe %s (pipes_open=%d)\n",
                 pipe_name, pipes_open));
 
+       talloc_set_destructor(p, close_internal_rpc_pipe_hnd);
+
        return p;
 }
 
        return p;
 }
 
@@ -1136,7 +1137,7 @@ bool close_rpc_pipe_hnd(smb_np_struct *p)
                return False;
        }
 
                return False;
        }
 
-       p->namedpipe_close(p->np_state);
+       TALLOC_FREE(p->np_state);
 
        bitmap_clear(bmap, p->pnum - pipe_handle_offset);
 
 
        bitmap_clear(bmap, p->pnum - pipe_handle_offset);
 
@@ -1179,9 +1180,8 @@ void pipe_close_conn(connection_struct *conn)
  Close an rpc pipe.
 ****************************************************************************/
 
  Close an rpc pipe.
 ****************************************************************************/
 
-static bool close_internal_rpc_pipe_hnd(void *np_conn)
+static int close_internal_rpc_pipe_hnd(struct pipes_struct *p)
 {
 {
-       pipes_struct *p = (pipes_struct *)np_conn;
        if (!p) {
                DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n"));
                return False;
        if (!p) {
                DEBUG(0,("Invalid pipe in close_internal_rpc_pipe_hnd\n"));
                return False;