summaryrefslogtreecommitdiff
path: root/source3/rpc_client/cli_connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_client/cli_connect.c')
-rw-r--r--source3/rpc_client/cli_connect.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c
index 81630c5125..0baa279711 100644
--- a/source3/rpc_client/cli_connect.c
+++ b/source3/rpc_client/cli_connect.c
@@ -148,23 +148,50 @@ terminate client connection
void cli_connection_free(struct cli_connection *con)
{
BOOL closed;
+ int i;
+
+ if (con->cli != NULL)
+ {
+ cli_nt_session_close(con->cli, con->fnum);
+ cli_net_use_del(con->srv_name, &con->usr_creds, False, &closed);
+ }
- cli_nt_session_close(con->cli, con->fnum);
- cli_net_use_del(con->srv_name, &con->usr_creds, False, &closed);
+ if (closed)
+ {
+ for (i = 0; i < num_cons; i++)
+ {
+ if (con != con_list[i] && con_list[i]->cli == con->cli)
+ {
+ /* WHOOPS! fnum already open: too bad!!! */
+ con_list[i]->cli = NULL;
+ con_list[i]->fnum = 0xffff;
+ }
+ }
+ }
con->cli = NULL;
if (con->srv_name != NULL)
{
free(con->srv_name);
+ con->srv_name = NULL;
}
if (con->pipe_name != NULL)
{
free(con->pipe_name);
+ con->pipe_name = NULL;
}
memset(&con->usr_creds, 0, sizeof(con->usr_creds));
+ for (i = 0; i < num_cons; i++)
+ {
+ if (con == con_list[i])
+ {
+ con_list[i] = NULL;
+ }
+ }
+
free(con);
}