[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Mon Mar 29 10:15:10 MDT 2010


The branch, master has been updated
       via  cac9981... s3:rpc_client: remove more unused code
       via  13cf592... s3:rpc_client: remove unused code, we handle transport failures in the transport layer now
       via  6bd5a2a... s3:winbindd_reconnect: don't only reconnect on NT_STATUS_UNSUCCESSFUL
       via  94a4bcd... s3:winbindd_cm: invalidate connection if cm_connect_netlogon() fails
       via  4f391fe... s3:winbindd: consistently use TALLOC_FREE(conn->foo_pipe) is we create a new connection
       via  d980c06... s3:winbindd_cm: use rpccli_is_connected() helper function
       via  408a3eb... s3:winbindd_cm: use cli_state_is_connected() helper function
       via  3e70da3... s3:rpc_client: return at least 10 sec as old timeout in rpccli_set_timeout() instead of 0
       via  99664ad... s3:rpc_client: add set_timeout hook to rpc_cli_transport
       via  4f41b53... s3:rpc_client: add rpccli_is_connected()
       via  dc09b12... s3:rpc_client: don't mix layers and keep a reference to cli_state in the caller
       via  5f8fc63... s3:rpc_transport_np: add comment about bad usage in a destructor
       via  b862351... s3:rpc_transport_np: use cli_state_is_connected() helper
       via  d7bf30e... s3:libsmb: add cli_state_is_connected() function
       via  47e10ab... s3:libsmb: don't let cli_shutdown() segfault with a NULL cli_state
      from  1ec2b2f... ldap.py: Fix syntax error.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cac9981b1a88a37c703a76a951b0691fa4ba7b4b
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:54:29 2010 +0100

    s3:rpc_client: remove more unused code
    
    metze

commit 13cf592bb8478453dccd4d78bdb4dabec7aeddc2
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:29:05 2010 +0100

    s3:rpc_client: remove unused code, we handle transport failures in the transport layer now
    
    metze

commit 6bd5a2a3739938f95fce23ab2da652c9b5a48111
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 29 16:31:13 2010 +0200

    s3:winbindd_reconnect: don't only reconnect on NT_STATUS_UNSUCCESSFUL
    
    metze

commit 94a4bcd2f0c0464e192556679c6636639cb307ea
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:25:47 2010 +0100

    s3:winbindd_cm: invalidate connection if cm_connect_netlogon() fails
    
    metze

commit 4f391fedac7111683d13f2d79fee7c0dbc27f86e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:17:07 2010 +0100

    s3:winbindd: consistently use TALLOC_FREE(conn->foo_pipe) is we create a new connection
    
    metze

commit d980c06a994d032a833adc8d56d2f2c037f8fdaf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:15:57 2010 +0100

    s3:winbindd_cm: use rpccli_is_connected() helper function
    
    metze

commit 408a3eb35a0e61b5d66a3b48ebbd1a6796672d0f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:14:02 2010 +0100

    s3:winbindd_cm: use cli_state_is_connected() helper function
    
    metze

commit 3e70da3f470eeb122f95477fb48d89939f501b3e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sun Mar 28 19:34:34 2010 +0200

    s3:rpc_client: return at least 10 sec as old timeout in rpccli_set_timeout() instead of 0
    
    metze

commit 99664ad15460530b6fb44957b6c57823f09884bf
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:51:51 2010 +0100

    s3:rpc_client: add set_timeout hook to rpc_cli_transport
    
    metze

commit 4f41b53487ac9bc96c7960e8edab464558656373
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 15:00:38 2010 +0100

    s3:rpc_client: add rpccli_is_connected()
    
    metze

commit dc09b12681ea0e6d4c2b0f1c99dfeb1f23019c65
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 29 14:58:19 2010 +0200

    s3:rpc_client: don't mix layers and keep a reference to cli_state in the caller
    
    We should not rely on the backend to have a reference to the cli_state.
    This will make it possible for the backend to set its cli_state reference
    to NULL, when the transport is dead.
    
    metze

commit 5f8fc63515a02aaf55719cb8d3be8ce695178fe9
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 14:10:25 2010 +0100

    s3:rpc_transport_np: add comment about bad usage in a destructor
    
    metze

commit b862351da8624df893ec77e020a456c1d23c58ed
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 14:08:42 2010 +0100

    s3:rpc_transport_np: use cli_state_is_connected() helper
    
    metze

commit d7bf30ef92031ffddcde3680b38e602510bcae24
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 25 13:20:56 2010 +0100

    s3:libsmb: add cli_state_is_connected() function
    
    metze

commit 47e10ab9a85960c78af807b66b99bcd139713644
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 29 15:07:34 2010 +0200

    s3:libsmb: don't let cli_shutdown() segfault with a NULL cli_state
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source3/include/client.h                |    4 +
 source3/include/proto.h                 |    6 +-
 source3/libsmb/clientgen.c              |    3 +
 source3/libsmb/clierror.c               |   18 +++++
 source3/rpc_client/cli_pipe.c           |   66 ++++++++++++-------
 source3/rpc_client/ndr.c                |   14 ----
 source3/rpc_client/rpc_transport_np.c   |  100 +++++++++++++++++++++++++----
 source3/rpc_client/rpc_transport_smbd.c |  105 ++++++++++++++++++++++++++-----
 source3/rpc_client/rpc_transport_sock.c |   91 +++++++++++++--------------
 source3/winbindd/winbindd_cm.c          |   35 +++++------
 source3/winbindd/winbindd_reconnect.c   |   73 +++++++++++++++++----
 11 files changed, 360 insertions(+), 155 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/client.h b/source3/include/client.h
index 72cea4a..457c02a 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -110,6 +110,10 @@ struct rpc_cli_transport {
 	 */
 	NTSTATUS (*trans_recv)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			       uint8_t **prdata, uint32_t *prdata_len);
+
+	bool (*is_connected)(void *priv);
+	unsigned int (*set_timeout)(void *priv, unsigned int timeout);
+
 	void *priv;
 };
 
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c270a1d..2708c3a 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2314,6 +2314,7 @@ bool cli_is_dos_error(struct cli_state *cli);
 NTSTATUS cli_get_nt_error(struct cli_state *cli);
 void cli_set_nt_error(struct cli_state *cli, NTSTATUS status);
 void cli_reset_error(struct cli_state *cli);
+bool cli_state_is_connected(struct cli_state *cli);
 
 /* The following definitions come from libsmb/clifile.c  */
 
@@ -5290,6 +5291,7 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
 		       struct cli_pipe_auth_data *auth);
 unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
 				unsigned int timeout);
+bool rpccli_is_connected(struct rpc_pipe_client *rpc_cli);
 bool rpccli_get_pwd_hash(struct rpc_pipe_client *cli, uint8_t nt_hash[16]);
 NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
 			       struct cli_pipe_auth_data **presult);
@@ -5383,7 +5385,6 @@ NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
 			       const struct ndr_syntax_id *abstract_syntax,
 			       struct rpc_cli_transport **presult);
 struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
-void rpccli_close_np_fd(struct rpc_pipe_client *p);
 
 /* The following definitions come from rpc_client/rpc_transport_smbd.c  */
 
@@ -5420,9 +5421,6 @@ struct cli_state *rpc_pipe_smbd_smb_conn(struct rpc_pipe_client *p);
 
 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
 				 struct rpc_cli_transport **presult);
-int rpccli_set_sock_timeout(struct rpc_pipe_client *rpccli, int timeout);
-void rpccli_close_sock_fd(struct rpc_pipe_client *rpccli);
-bool rpc_pipe_tcp_connection_ok(struct rpc_pipe_client *rpccli);
 
 /* The following definitions come from rpc_client/cli_samr.c  */
 
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 1b43809..c530c14 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -737,6 +737,9 @@ static void _cli_shutdown(struct cli_state *cli)
 void cli_shutdown(struct cli_state *cli)
 {
 	struct cli_state *cli_head;
+	if (cli == NULL) {
+		return;
+	}
 	DLIST_HEAD(cli, cli_head);
 	if (cli_head == cli) {
 		/*
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 54f8a7a..015afb1 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -359,3 +359,21 @@ void cli_reset_error(struct cli_state *cli)
 		SSVAL(cli->inbuf,smb_err,0);
 	}
 }
+
+bool cli_state_is_connected(struct cli_state *cli)
+{
+	if (cli == NULL) {
+		return false;
+	}
+
+	if (!cli->initialised) {
+		return false;
+	}
+
+	if (cli->fd == -1) {
+		return false;
+	}
+
+	return true;
+}
+
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index af1ebd6..8d33d77 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -3064,33 +3064,40 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
 	return status;
 }
 
+#define RPCCLI_DEFAULT_TIMEOUT 10000 /* 10 seconds. */
+
 unsigned int rpccli_set_timeout(struct rpc_pipe_client *rpc_cli,
 				unsigned int timeout)
 {
-	struct cli_state *cli;
+	unsigned int old;
 
-	if (rpc_cli->transport->transport == NCACN_NP) {
-		cli = rpc_pipe_np_smb_conn(rpc_cli);
-		if (cli == NULL) {
-			return 0;
-		}
-		return cli_set_timeout(cli, timeout);
+	if (rpc_cli->transport == NULL) {
+		return RPCCLI_DEFAULT_TIMEOUT;
 	}
 
-	if (rpc_cli->transport->transport == NCACN_IP_TCP ||
-	    rpc_cli->transport->transport == NCALRPC) {
-		return rpccli_set_sock_timeout(rpc_cli, timeout);
+	if (rpc_cli->transport->set_timeout == NULL) {
+		return RPCCLI_DEFAULT_TIMEOUT;
 	}
 
-	if (rpc_cli->transport->transport == NCACN_INTERNAL) {
-		cli = rpc_pipe_smbd_smb_conn(rpc_cli);
-		if (!cli) {
-			return 0;
-		}
-		return cli_set_timeout(cli, timeout);
+	old = rpc_cli->transport->set_timeout(rpc_cli->transport->priv, timeout);
+	if (old == 0) {
+		return RPCCLI_DEFAULT_TIMEOUT;
 	}
 
-	return 0;
+	return old;
+}
+
+bool rpccli_is_connected(struct rpc_pipe_client *rpc_cli)
+{
+	if (rpc_cli == NULL) {
+		return false;
+	}
+
+	if (rpc_cli->transport == NULL) {
+		return false;
+	}
+
+	return rpc_cli->transport->is_connected(rpc_cli->transport->priv);
 }
 
 bool rpccli_get_pwd_hash(struct rpc_pipe_client *rpc_cli, uint8_t nt_hash[16])
@@ -3599,14 +3606,14 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
 	return status;
 }
 
-static int rpc_pipe_client_np_destructor(struct rpc_pipe_client *p)
-{
+struct rpc_pipe_client_np_ref {
 	struct cli_state *cli;
+	struct rpc_pipe_client *pipe;
+};
 
-	cli = rpc_pipe_np_smb_conn(p);
-	if (cli != NULL) {
-		DLIST_REMOVE(cli->pipe_list, p);
-	}
+static int rpc_pipe_client_np_ref_destructor(struct rpc_pipe_client_np_ref *np_ref)
+{
+	DLIST_REMOVE(np_ref->cli->pipe_list, np_ref->pipe);
 	return 0;
 }
 
@@ -3629,6 +3636,7 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
 {
 	struct rpc_pipe_client *result;
 	NTSTATUS status;
+	struct rpc_pipe_client_np_ref *np_ref;
 
 	/* sanity check to protect against crashes */
 
@@ -3667,8 +3675,16 @@ static NTSTATUS rpc_pipe_open_np(struct cli_state *cli,
 
 	result->transport->transport = NCACN_NP;
 
-	DLIST_ADD(cli->pipe_list, result);
-	talloc_set_destructor(result, rpc_pipe_client_np_destructor);
+	np_ref = talloc(result->transport, struct rpc_pipe_client_np_ref);
+	if (np_ref == NULL) {
+		TALLOC_FREE(result);
+		return NT_STATUS_NO_MEMORY;
+	}
+	np_ref->cli = cli;
+	np_ref->pipe = result;
+
+	DLIST_ADD(np_ref->cli->pipe_list, np_ref->pipe);
+	talloc_set_destructor(np_ref, rpc_pipe_client_np_ref_destructor);
 
 	*presult = result;
 	return NT_STATUS_OK;
diff --git a/source3/rpc_client/ndr.c b/source3/rpc_client/ndr.c
index 4e8634d..5675878 100644
--- a/source3/rpc_client/ndr.c
+++ b/source3/rpc_client/ndr.c
@@ -183,20 +183,6 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
 
 	status = cli_do_rpc_ndr_recv(req, mem_ctx);
 
-	/*
-	 * NT_STATUS_IO_TIMEOUT indicates network problem,
-	 * tear the connection apart.
-	 */
-	if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
-		if (cli->transport->transport == NCACN_IP_TCP ||
-		    cli->transport->transport == NCALRPC) {
-			rpccli_close_sock_fd(cli);
-		}
-
-		if (cli->transport->transport == NCACN_NP) {
-			rpccli_close_np_fd(cli);
-		}
-	}
  fail:
 	TALLOC_FREE(frame);
 	return status;
diff --git a/source3/rpc_client/rpc_transport_np.c b/source3/rpc_client/rpc_transport_np.c
index de734fe..e00c1f3 100644
--- a/source3/rpc_client/rpc_transport_np.c
+++ b/source3/rpc_client/rpc_transport_np.c
@@ -28,13 +28,51 @@ struct rpc_transport_np_state {
 	uint16_t fnum;
 };
 
+static bool rpc_np_is_connected(void *priv)
+{
+	struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
+		priv, struct rpc_transport_np_state);
+	bool ok;
+
+	if (np_transport->cli == NULL) {
+		return false;
+	}
+
+	ok = cli_state_is_connected(np_transport->cli);
+	if (!ok) {
+		np_transport->cli = NULL;
+		return false;
+	}
+
+	return true;
+}
+
+static unsigned int rpc_np_set_timeout(void *priv, unsigned int timeout)
+{
+	struct rpc_transport_np_state *np_transport = talloc_get_type_abort(
+		priv, struct rpc_transport_np_state);
+	bool ok;
+
+	if (np_transport->cli == NULL) {
+		return false;
+	}
+
+	ok = rpc_np_is_connected(np_transport);
+	if (!ok) {
+		return 0;
+	}
+
+	return cli_set_timeout(np_transport->cli, timeout);
+}
+
 static int rpc_transport_np_state_destructor(struct rpc_transport_np_state *s)
 {
-	if (s->cli->fd == -1) {
+	if (!rpc_np_is_connected(s)) {
 		DEBUG(10, ("socket was closed, no need to send close request.\n"));
 		return 0;
 	}
-	
+
+	/* TODO: do not use a sync call with a destructor!!! */
 	if (!NT_STATUS_IS_OK(cli_close(s->cli, s->fnum))) {
 		DEBUG(1, ("rpc_transport_np_state_destructor: cli_close "
 			  "failed on pipe %s. Error was %s\n", s->pipe_name,
@@ -48,6 +86,7 @@ static int rpc_transport_np_state_destructor(struct rpc_transport_np_state *s)
 }
 
 struct rpc_np_write_state {
+	struct rpc_transport_np_state *np_transport;
 	size_t size;
 	size_t written;
 };
@@ -63,13 +102,23 @@ static struct tevent_req *rpc_np_write_send(TALLOC_CTX *mem_ctx,
 		priv, struct rpc_transport_np_state);
 	struct tevent_req *req, *subreq;
 	struct rpc_np_write_state *state;
+	bool ok;
 
 	req = tevent_req_create(mem_ctx, &state, struct rpc_np_write_state);
 	if (req == NULL) {
 		return NULL;
 	}
+
+	ok = rpc_np_is_connected(np_transport);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_CONNECTION_INVALID);
+		return tevent_req_post(req, ev);
+	}
+
+	state->np_transport = np_transport;
 	state->size = size;
 
+
 	subreq = cli_write_andx_send(mem_ctx, ev, np_transport->cli,
 				     np_transport->fnum,
 				     8, /* 8 means message mode. */
@@ -92,6 +141,7 @@ static void rpc_np_write_done(struct tevent_req *subreq)
 	status = cli_write_andx_recv(subreq, &state->written);
 	TALLOC_FREE(subreq);
 	if (!NT_STATUS_IS_OK(status)) {
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, status);
 		return;
 	}
@@ -112,6 +162,7 @@ static NTSTATUS rpc_np_write_recv(struct tevent_req *req, ssize_t *pwritten)
 }
 
 struct rpc_np_read_state {
+	struct rpc_transport_np_state *np_transport;
 	uint8_t *data;
 	size_t size;
 	ssize_t received;
@@ -128,11 +179,20 @@ static struct tevent_req *rpc_np_read_send(TALLOC_CTX *mem_ctx,
 		priv, struct rpc_transport_np_state);
 	struct tevent_req *req, *subreq;
 	struct rpc_np_read_state *state;
+	bool ok;
 
 	req = tevent_req_create(mem_ctx, &state, struct rpc_np_read_state);
 	if (req == NULL) {
 		return NULL;
 	}
+
+	ok = rpc_np_is_connected(np_transport);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_CONNECTION_INVALID);
+		return tevent_req_post(req, ev);
+	}
+
+	state->np_transport = np_transport;
 	state->data = data;
 	state->size = size;
 
@@ -170,18 +230,21 @@ static void rpc_np_read_done(struct tevent_req *subreq)
 	}
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(subreq);
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, status);
 		return;
 	}
 
 	if (state->received > state->size) {
 		TALLOC_FREE(subreq);
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
 		return;
 	}
 
 	if (state->received == 0) {
 		TALLOC_FREE(subreq);
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, NT_STATUS_PIPE_BROKEN);
 		return;
 	}
@@ -205,6 +268,7 @@ static NTSTATUS rpc_np_read_recv(struct tevent_req *req, ssize_t *preceived)
 }
 
 struct rpc_np_trans_state {
+	struct rpc_transport_np_state *np_transport;
 	uint16_t setup[2];
 	uint32_t max_rdata_len;
 	uint8_t *rdata;
@@ -223,12 +287,20 @@ static struct tevent_req *rpc_np_trans_send(TALLOC_CTX *mem_ctx,
 		priv, struct rpc_transport_np_state);
 	struct tevent_req *req, *subreq;
 	struct rpc_np_trans_state *state;
+	bool ok;
 
 	req = tevent_req_create(mem_ctx, &state, struct rpc_np_trans_state);
 	if (req == NULL) {
 		return NULL;
 	}
 
+	ok = rpc_np_is_connected(np_transport);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_CONNECTION_INVALID);
+		return tevent_req_post(req, ev);
+	}
+
+	state->np_transport = np_transport;
 	state->max_rdata_len = max_rdata_len;
 
 	SSVAL(state->setup+0, 0, TRANSACT_DCERPCCMD);
@@ -264,16 +336,19 @@ static void rpc_np_trans_done(struct tevent_req *subreq)
 		status = NT_STATUS_OK;
 	}
 	if (!NT_STATUS_IS_OK(status)) {
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, status);
 		return;
 	}
 
 	if (state->rdata_len > state->max_rdata_len) {
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
 		return;
 	}
 
 	if (state->rdata_len == 0) {
+		state->np_transport->cli = NULL;
 		tevent_req_nterror(req, NT_STATUS_PIPE_BROKEN);
 		return;
 	}
@@ -310,6 +385,7 @@ struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
 {
 	struct tevent_req *req, *subreq;
 	struct rpc_transport_np_init_state *state;
+	bool ok;
 
 	req = tevent_req_create(mem_ctx, &state,
 				struct rpc_transport_np_init_state);
@@ -317,6 +393,12 @@ struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
+	ok = cli_state_is_connected(cli);
+	if (!ok) {
+		tevent_req_nterror(req, NT_STATUS_CONNECTION_INVALID);
+		return tevent_req_post(req, ev);
+	}
+
 	state->transport = talloc(state, struct rpc_cli_transport);
 	if (tevent_req_nomem(state->transport, req)) {
 		return tevent_req_post(req, ev);
@@ -382,6 +464,8 @@ NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
 	state->transport->read_recv = rpc_np_read_recv;
 	state->transport->trans_send = rpc_np_trans_send;
 	state->transport->trans_recv = rpc_np_trans_recv;
+	state->transport->is_connected = rpc_np_is_connected;
+	state->transport->set_timeout = rpc_np_set_timeout;
 
 	*presult = talloc_move(mem_ctx, &state->transport);
 	return NT_STATUS_OK;
@@ -429,15 +513,3 @@ struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p)
 	}
 	return state->cli;
 }
-
-void rpccli_close_np_fd(struct rpc_pipe_client *p)
-{
-	struct cli_state *cli = rpc_pipe_np_smb_conn(p);
-	if (cli) {
-		if (cli->fd != -1) {
-			close(cli->fd);
-			cli->fd = -1;
-		}
-	}
-	return;
-}
diff --git a/source3/rpc_client/rpc_transport_smbd.c b/source3/rpc_client/rpc_transport_smbd.c
index 929e553..57fac68 100644
--- a/source3/rpc_client/rpc_transport_smbd.c
+++ b/source3/rpc_client/rpc_transport_smbd.c
@@ -419,8 +419,71 @@ NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx,
 	return status;
 }
 
+static void rpc_smbd_disconnect(struct rpc_transport_smbd_state *transp)
+{
+	if (transp == NULL) {
+		return;
+	}
+
+	if (transp->conn == NULL) {
+		return;
+	}
+
+	if (transp->conn->cli == NULL) {
+		return;
+	}
+
+	if (transp->conn->cli->fd != -1) {
+		close(transp->conn->cli->fd);
+		transp->conn->cli->fd = -1;
+	}
+
+	transp->conn = NULL;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list