rpc_client: add a destructor to close the socket for pipes over tcp.
authorVolker Lendecke <vl@samba.org>
Tue, 20 May 2008 16:25:42 +0000 (18:25 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 21 May 2008 21:35:26 +0000 (23:35 +0200)
used in rpc_pipe_open_tcp() and rpc_pipe_open_ncalrpc().

source/rpc_client/cli_pipe.c

index 6bd240dd81cd4a3ed3abb02993a8088a12011c59..9908c69674e9c11c3f89a4fd5295ce4bd2f1da66 100644 (file)
@@ -2503,6 +2503,12 @@ NTSTATUS rpccli_kerberos_bind_data(TALLOC_CTX *mem_ctx,
 #endif
 }
 
+static int rpc_pipe_sock_destructor(struct rpc_pipe_client *p)
+{
+       close(p->trans.sock.fd);
+       return 0;
+}
+
 /********************************************************************
  Create a rpc pipe client struct, connecting to a tcp port
  ********************************************************************/
@@ -2547,6 +2553,8 @@ NTSTATUS rpc_pipe_open_tcp(TALLOC_CTX *mem_ctx, const char *host,
                goto fail;
        }
 
+       talloc_set_destructor(result, rpc_pipe_sock_destructor);
+
        *presult = result;
        return NT_STATUS_OK;
 
@@ -2593,6 +2601,8 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
                goto fail;
        }
 
+       talloc_set_destructor(result, rpc_pipe_sock_destructor);
+
        result->dc = TALLOC_ZERO_P(result, struct dcinfo);
        if (result->dc == NULL) {
                status = NT_STATUS_NO_MEMORY;