ok. this is where it gets interesting. client states are now maintained
authorLuke Leighton <lkcl@samba.org>
Tue, 30 Nov 1999 00:08:39 +0000 (00:08 +0000)
committerLuke Leighton <lkcl@samba.org>
Tue, 30 Nov 1999 00:08:39 +0000 (00:08 +0000)
by cli_net_use_add() and cli_net_use_del().  MSRPC connections are
established with cli_connection_init(), and automatically unlinked with
cli_connection_unlink.  client states are _reused_ by cli_connection_init.
(This used to be commit 0fcd8ce0967169362bd126a28aa309401abdf17d)

source3/rpc_client/cli_connect.c

index 81630c51257f9350f1f2688d00e3f36cacc0a2f3..0baa279711bb310653d740012bcfe13c9a30269a 100644 (file)
@@ -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);
 }