Fix a race condition in vfs_aio_fork with gpfs share modes
authorVolker Lendecke <vl@samba.org>
Mon, 18 May 2009 07:36:16 +0000 (09:36 +0200)
committerMichael Adam <obnox@samba.org>
Mon, 18 May 2009 09:56:19 +0000 (11:56 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
source/modules/vfs_aio_fork.c

index 28428f2e498ad2a9646a87b9f5a003c5eaa3908a..864fd4229d83e319732fbc798eca605199a4dac7 100644 (file)
@@ -359,6 +359,14 @@ static void aio_child_loop(int sockfd, struct mmap_area *map)
                        ret_struct.ret_errno = errno;
                }
 
+               /*
+                * Close the fd before telling our parent we're done. The
+                * parent might close and re-open the file very quickly, and
+                * with system-level share modes (GPFS) we would get an
+                * unjustified SHARING_VIOLATION.
+                */
+               close(fd);
+
                ret = write_data(sockfd, (char *)&ret_struct,
                                 sizeof(ret_struct));
                if (ret != sizeof(ret_struct)) {
@@ -366,8 +374,6 @@ static void aio_child_loop(int sockfd, struct mmap_area *map)
                                   strerror(errno)));
                        exit(2);
                }
-
-               close(fd);
        }
 }