r7704: - fixed open_nbt_connection() to return NULL when the connection failed
authorAndrew Tridgell <tridge@samba.org>
Sat, 18 Jun 2005 00:02:36 +0000 (00:02 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:18:23 +0000 (13:18 -0500)
- got rid of smbcli_shutdown() and use talloc_free() instead.
(This used to be commit 1011b1bf51d420d6702ef448c894ea8ebeafa284)

source4/auth/auth_server.c
source4/client/client.c
source4/client/smbmount.c
source4/client/smbspool.c
source4/libcli/cliconnect.c
source4/torture/gentest.c
source4/torture/locktest.c
source4/torture/locktest2.c
source4/torture/torture.c

index 8e1c712f5ef68faf1e0e479572692c842923764a..fc87cd91f65e31ab99c713d60adcec0dc6030bec 100644 (file)
@@ -78,7 +78,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
        if (!connected_ok) {
                release_server_mutex();
                DEBUG(0,("password server not available\n"));
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return NULL;
        }
        
@@ -86,7 +86,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
                                             desthost, &dest_ip)) {
                release_server_mutex();
                DEBUG(1,("password server fails session request\n"));
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return NULL;
        }
        
@@ -99,7 +99,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
        if (!smbcli_negprot(cli)) {
                DEBUG(1,("%s rejected the negprot\n",desthost));
                release_server_mutex();
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return NULL;
        }
 
@@ -107,7 +107,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
            !(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
                DEBUG(1,("%s isn't in user level security mode\n",desthost));
                release_server_mutex();
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return NULL;
        }
 
@@ -121,7 +121,7 @@ static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx)
                DEBUG(0,("%s rejected the initial session setup (%s)\n",
                         desthost, smbcli_errstr(cli)));
                release_server_mutex();
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return NULL;
        }
        
@@ -140,7 +140,7 @@ static void free_server_private_data(void **private_data_pointer)
 {
        struct smbcli_state **cli = (struct smbcli_state **)private_data_pointer;
        if (*cli && (*cli)->initialised) {
-               smbcli_shutdown(*cli);
+               talloc_free(*cli);
        }
 }
 
@@ -170,7 +170,7 @@ static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_conte
                } else if (cli->secblob.length < 8) {
                        /* We can't do much if we don't get a full challenge */
                        DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
-                       smbcli_shutdown(cli);
+                       talloc_free(cli);
                        return data_blob(NULL, 0);
                }
 
@@ -361,7 +361,7 @@ use this machine as the password server.\n"));
        }
 
        if (locally_made_cli) {
-               smbcli_shutdown(cli);
+               talloc_free(cli);
        }
 
        return(nt_status);
index a24fd7bfd368652fb3dd814d0002190d821f3a17..5e5d7e5dcde38048bbe4e8c96fed92e216171a25 100644 (file)
@@ -1069,7 +1069,7 @@ static BOOL do_altname(char *name)
 ****************************************************************************/
 static int cmd_quit(const char **cmd_ptr)
 {
-       smbcli_shutdown(cli);
+       talloc_free(cli);
        exit(0);
        /* NOTREACHED */
        return 0;
@@ -1263,7 +1263,7 @@ static int do_put(char *rname, char *lname, BOOL reput)
        }
 
        if (f == x_stdin) {
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                exit(0);
        }
        
@@ -3251,7 +3251,7 @@ static int process(char *base_directory)
                process_stdin();
        }
   
-       smbcli_shutdown(cli);
+       talloc_free(cli);
        return rc;
 }
 
@@ -3287,12 +3287,12 @@ static int do_message_op(void)
 
        if (!smbcli_transport_establish(cli, &calling, &called)) {
                d_printf("session request failed\n");
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return 1;
        }
 
        send_message();
-       smbcli_shutdown(cli);
+       talloc_free(cli);
 
        return 0;
 }
index 45c5f703cea9b909ba536ab9cf1b2bab4eaac13b..5c541a7e4f7576c39a9db3989bb0c6acc0961687 100644 (file)
@@ -151,7 +151,7 @@ static struct smbcli_state *do_connection(char *the_service)
            !smbcli_connect(c, server_n, &ip)) {
                DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n));
                if (c) {
-                       smbcli_shutdown(c);
+                       talloc_free(c);
                }
                return NULL;
        }
@@ -170,7 +170,7 @@ static struct smbcli_state *do_connection(char *the_service)
                char *p;
                DEBUG(0,("%d: session request to %s failed (%s)\n", 
                         sys_getpid(), called.name, smbcli_errstr(c)));
-               smbcli_shutdown(c);
+               talloc_free(c);
                if ((p=strchr_m(called.name, '.'))) {
                        *p = 0;
                        goto again;
@@ -186,7 +186,7 @@ static struct smbcli_state *do_connection(char *the_service)
 
        if (!smbcli_negprot(c)) {
                DEBUG(0,("%d: protocol negotiation failed\n", sys_getpid()));
-               smbcli_shutdown(c);
+               talloc_free(c);
                return NULL;
        }
 
@@ -220,7 +220,7 @@ static struct smbcli_state *do_connection(char *the_service)
                                !smbcli_session_setup(c, "", "", 0, "", 0, workgroup)) {
                        DEBUG(0,("%d: session setup failed: %s\n",
                                sys_getpid(), smbcli_errstr(c)));
-                       smbcli_shutdown(c);
+                       talloc_free(c);
                        return NULL;
                }
                DEBUG(0,("Anonymous login successful\n"));
@@ -231,7 +231,7 @@ static struct smbcli_state *do_connection(char *the_service)
        if (!smbcli_tconX(c, share, "?????", password, strlen(password)+1)) {
                DEBUG(0,("%d: tree connect failed: %s\n",
                         sys_getpid(), smbcli_errstr(c)));
-               smbcli_shutdown(c);
+               talloc_free(c);
                return NULL;
        }
 
@@ -379,7 +379,7 @@ static void send_fs_socket(char *the_service, char *mount_point, struct smbcli_s
 
                   If we don't do this we will "leak" sockets and memory on
                   each reconnection we have to make. */
-               smbcli_shutdown(c);
+               talloc_free(c);
                c = NULL;
 
                if (!closed) {
index 2e7afc5ec4ecc5890a31d0c7968f0e58564b7e70..c975e0477148fabb3e66f60381f1c1a7874f3825 100644 (file)
@@ -233,7 +233,7 @@ static int          smb_print(struct smbcli_state *, char *, FILE *);
     if ((status = smb_print(cli, argv[3] /* title */, fp)) != 0)
       break;
 
-  smbcli_shutdown(cli);
+  talloc_free(cli);
 
  /*
   * Return the queue status...
index 0009151429837729bd5ff24d178b686b2e27498a..489aea82dd1798ca6f76651d4438422661cb26f4 100644 (file)
@@ -183,14 +183,6 @@ struct smbcli_state *smbcli_state_init(TALLOC_CTX *mem_ctx)
        return cli;
 }
 
-/****************************************************************************
- Shutdown a client structure.
-****************************************************************************/
-void smbcli_shutdown(struct smbcli_state *cli)
-{
-       talloc_free(cli);
-}
-
 /*
   parse a //server/share type UNC name
 */
index a9d162b5407aea107ba51bb8ff98ed59f6daec88..d6f5046820f14179f11c6100da94c850436b3c49 100644 (file)
@@ -164,7 +164,7 @@ static BOOL connect_servers(void)
                for (j=0;j<NINSTANCES;j++) {
                        if (servers[i].cli[j]) {
                                smbcli_tdis(servers[i].cli[j]);
-                               smbcli_shutdown(servers[i].cli[j]);
+                               talloc_free(servers[i].cli[j]);
                                servers[i].cli[j] = NULL;
                        }
                }
index 4b4e9d3bd338c02fc6f48e658cc299a284720e49..62eabeb6880874aa28b203ebb8f06f8fc8817eb3 100644 (file)
@@ -150,7 +150,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum
                                        fnum[server][conn][f] = -1;
                                }
                        }
-                       smbcli_shutdown(cli[server][conn]);
+                       talloc_free(cli[server][conn]);
                }
                cli[server][conn] = connect_one(share[server], server);
                if (!cli[server][conn]) {
index 4bd99cd5d083d89e7603051fca7dfba1a96e531e..e5cd8a60aff30074c58e6a10bdb88ef78da54db9 100644 (file)
@@ -196,7 +196,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
                                smbcli_close(cli[server][conn], fnum[server][fstype][conn][f]);
                        }
                        smbcli_ulogoff(cli[server][conn]);
-                       smbcli_shutdown(cli[server][conn]);
+                       talloc_free(cli[server][conn]);
                }
                cli[server][conn] = connect_one(share[server]);
                if (!cli[server][conn]) {
index 5036822aa4c0f184f7f677bc22ee82ee31978d9f..1ca4046a49cb02693570db51e5225bb829b6c06e 100644 (file)
@@ -56,21 +56,24 @@ static struct smbcli_state *open_nbt_connection(void)
        cli = smbcli_state_init(NULL);
        if (!cli) {
                printf("Failed initialize smbcli_struct to connect with %s\n", host);
-               return NULL;
+               goto failed;
        }
 
        if (!smbcli_socket_connect(cli, host)) {
                printf("Failed to connect with %s\n", host);
-               return cli;
+               goto failed;
        }
 
        if (!smbcli_transport_establish(cli, &calling, &called)) {
                printf("%s rejected the session\n",host);
-               smbcli_shutdown(cli);
-               return NULL;
+               goto failed;
        }
 
        return cli;
+
+failed:
+       talloc_free(cli);
+       return NULL;
 }
 
 BOOL torture_open_connection_share(struct smbcli_state **c, 
@@ -112,7 +115,7 @@ BOOL torture_close_connection(struct smbcli_state *c)
                printf("tdis failed (%s)\n", smbcli_errstr(c->tree));
                ret = False;
        }
-       smbcli_shutdown(c);
+       talloc_free(c);
        return ret;
 }
 
@@ -489,7 +492,7 @@ static BOOL run_tcon_test(void)
        if (NT_STATUS_IS_ERR(smbcli_tconX(cli, share, "?????", password))) {
                printf("%s refused 2nd tree connect (%s)\n", host,
                           smbcli_errstr(cli->tree));
-               smbcli_shutdown(cli);
+               talloc_free(cli);
                return False;
        }
 
@@ -649,7 +652,7 @@ static BOOL run_tcon_devtype_test(void)
        if (!tcon_devtest(cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE))
                ret = False;
 
-       smbcli_shutdown(cli1);
+       talloc_free(cli1);
 
        if (ret)
                printf("Passed tcondevtest\n");