r76: Fix smbfs problem with Tree Disconnect issued before smbfs starts its work.
authorAlexander Bokovoy <ab@samba.org>
Tue, 6 Apr 2004 11:45:02 +0000 (11:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:51:07 +0000 (10:51 -0500)
We use cli_state.smb_rw_error to pass this specific case into cli_close_connection()
from smbmount as smb_rw_error can have only selected number of states and
it is ignored in cli_close_connection().

Compiled and tested by Lars Mueller from SuSE on x86, x86_64, ppc, ppc64, s390 and
s390x.
(This used to be commit 738666ce0a310fae14476020fd6dac027b0e3ec5)

source3/client/smbmount.c
source3/include/smb.h
source3/libsmb/clientgen.c

index 6e8d9f5bca7e9710055d118ad331ef76b368d161..04bb103dae2f7916dd913bf71e910b202cdbec3a 100644 (file)
@@ -383,6 +383,7 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat
 
                   If we don't do this we will "leak" sockets and memory on
                   each reconnection we have to make. */
+               c->smb_rw_error = DO_NOT_DO_TDIS;
                cli_shutdown(c);
                c = NULL;
 
index 3ee6f01d34df68f3e11612e148bcfcf618f3cfa6..5d306be062483b248ee8c19268400102ead90b63 100644 (file)
@@ -82,6 +82,7 @@ typedef int BOOL;
 #define READ_ERROR 3
 #define WRITE_ERROR 4 /* This error code can go into the client smb_rw_error. */
 #define READ_BAD_SIG 5
+#define DO_NOT_DO_TDIS 6 /* cli_close_connection() check for this when smbfs wants to keep tree connected */
 
 #define DIR_STRUCT_SIZE 43
 
index 66edc3ce38bbc81d34a3e412b1da8e8c4a22e94c..6edc83c9d79088b0ce0c7da01a877ecbe301b450 100644 (file)
@@ -374,8 +374,12 @@ void cli_close_connection(struct cli_state *cli)
         * can remain active on the peer end, until some (long) timeout period
         * later.  This tree disconnect forces the peer to clean up, since the
         * connection will be going away.
+        *
+        * Also, do not do tree disconnect when cli->smb_rw_error is DO_NOT_DO_TDIS
+        * the only user for this so far is smbmount which passes opened connection
+        * down to kernel's smbfs module.
         */
-       if ( cli->cnum != (uint16)-1 )
+       if ( (cli->cnum != (uint16)-1) && (cli->smb_rw_error != DO_NOT_DO_TDIS ) )
                cli_tdis(cli);
         
        cli_nt_session_close(cli);