Earlier fix for smbmount timing window was the wrong patch.
[samba.git] / source / client / smbmount.c
index 364c28cdcdaa6951788240752a783e282117ad55..2cfd166688eba34f3d5a472fa8e711987950dbbb 100644 (file)
@@ -255,6 +255,7 @@ static void
 send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
 {
        int fd, closed = 0, res = 1;
+       int first_time = 1;
 
        while (1)
        {
@@ -290,6 +291,15 @@ send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
                }
 #endif
 
+               if( first_time ) {
+       /*
+        * Create the background process after trying the mount.
+        * to avoid race conditions with automount and other processes.
+        */
+                       first_time = 0;
+                       daemonize();
+               }
+
                /*
                 * Wait for a signal from smbfs ...
                 */
@@ -364,15 +374,6 @@ static void cmd_mount(char *inbuf,char *outbuf)
                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);
 }