From: Volker Lendecke Date: Mon, 18 May 2009 07:36:16 +0000 (+0200) Subject: Fix a race condition in vfs_aio_fork with gpfs share modes X-Git-Tag: tdb-1.1.5~501 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b9c5f04831216aa3d3b89fd2a81be12ac8592dd;p=thirdparty%2Fsamba.git Fix a race condition in vfs_aio_fork with gpfs share modes --- diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c index 8568ec39165..e706495a56f 100644 --- a/source3/modules/vfs_aio_fork.c +++ b/source3/modules/vfs_aio_fork.c @@ -357,6 +357,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)) { @@ -364,8 +372,6 @@ static void aio_child_loop(int sockfd, struct mmap_area *map) strerror(errno))); exit(2); } - - close(fd); } }