Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 8e7216b

Browse files
authored
Port to 2.0 Remove flock usage from InternalCreateFile in PAL (#16756)
This flock is causing issues on filesystems that don't support locking. An issue with loading managed assemblies from such a filesystem due to this issue was recently hit by someone. Since the locking in the PAL is not really needed and due to the advisory nature of the flock doesn't guarantee anything, this change is removing the flock from that function.
1 parent cb664a9 commit 8e7216b

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

src/pal/src/file/file.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,6 @@ CorUnix::InternalCreateFile(
453453
int filed = -1;
454454
int create_flags = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
455455
int open_flags = 0;
456-
int lock_mode = LOCK_SH;
457456

458457
// track whether we've created the file with the intended name,
459458
// so that it can be removed on failure exit
@@ -664,29 +663,6 @@ CorUnix::InternalCreateFile(
664663
dwCreationDisposition == OPEN_ALWAYS) &&
665664
!fFileExists;
666665

667-
668-
// While the lock manager is able to provide support for share modes within an instance of
669-
// the PAL, other PALs will ignore these locks. In order to support a basic level of cross
670-
// process locking, we'll use advisory locks. FILE_SHARE_NONE implies a exclusive lock on the
671-
// file and all other modes use a shared lock. While this is not as granular as Windows,
672-
// you can atleast implement a lock file using this.
673-
lock_mode = (dwShareMode == 0 /* FILE_SHARE_NONE */) ? LOCK_EX : LOCK_SH;
674-
675-
if(flock(filed, lock_mode | LOCK_NB) != 0)
676-
{
677-
TRACE("flock() failed; error is %s (%d)\n", strerror(errno), errno);
678-
if (errno == EWOULDBLOCK)
679-
{
680-
palError = ERROR_SHARING_VIOLATION;
681-
}
682-
else
683-
{
684-
palError = FILEGetLastErrorFromErrno();
685-
}
686-
687-
goto done;
688-
}
689-
690666
#ifndef O_DIRECT
691667
if ( dwFlagsAndAttributes & FILE_FLAG_NO_BUFFERING )
692668
{

0 commit comments

Comments
 (0)