Fixed timing window created by daemonize function. Smbmount was going daemon
authorMichael Warfield <mhw@samba.org>
Fri, 13 Nov 1998 20:32:22 +0000 (20:32 +0000)
committerMichael Warfield <mhw@samba.org>
Fri, 13 Nov 1998 20:32:22 +0000 (20:32 +0000)
before the mount was actually completed.  This caused weird problems when
used with autofs such as empty directories on first listing or files which
would appear in "ls" but would return "no such file or directory" under
"ls -l".  Note to Volker:  Initial attempt from CIFS conference didn't work.
Had to move daemonize function inside of loop after ioctl.

source/client/smbmount.c

index 4dd54db9549f30f43504aea42b8173492f75d3b3..364c28cdcdaa6951788240752a783e282117ad55 100644 (file)
@@ -358,18 +358,21 @@ static void cmd_mount(char *inbuf,char *outbuf)
 
        DEBUG(3, ("mount command: %s\n", mount_command));
 
 
        DEBUG(3, ("mount command: %s\n", mount_command));
 
-       /*
-        * Create the background process before trying the mount.
-        * (We delay closing files to allow diagnostic messages.)
-        */
-       daemonize();
-
-       /* The parent has exited here, the child handles the connection: */
        if ((retval = system(mount_command)) != 0)
        {
                DEBUG(0,("mount failed\n"));
                exit(1);
        }
        if ((retval = system(mount_command)) != 0)
        {
                DEBUG(0,("mount failed\n"));
                exit(1);
        }
+
+       /*
+        * Create the background process after trying the mount.
+        * to avoid race conditions with automount and other processes.
+        */
+       daemonize();
+
+       /* The parent has exited here, leave the daemon to deal with
+        * disconnects and reconnects
+         */
        send_fs_socket(mount_point, inbuf, outbuf);
 }      
 
        send_fs_socket(mount_point, inbuf, outbuf);
 }