Skip to content

Commit 5669afb

Browse files
committed
fs: drop old WSL1 hack.
1 parent ef5bb74 commit 5669afb

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

src/fs.cpp

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,20 @@ FileLock::~FileLock()
6060
}
6161
}
6262

63-
static bool IsWSL()
64-
{
65-
struct utsname uname_data;
66-
return uname(&uname_data) == 0 && std::string(uname_data.version).find("Microsoft") != std::string::npos;
67-
}
68-
6963
bool FileLock::TryLock()
7064
{
7165
if (fd == -1) {
7266
return false;
7367
}
7468

75-
// Exclusive file locking is broken on WSL using fcntl (issue #18622)
76-
// This workaround can be removed once the bug on WSL is fixed
77-
static const bool is_wsl = IsWSL();
78-
if (is_wsl) {
79-
if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
80-
reason = GetErrorReason();
81-
return false;
82-
}
83-
} else {
84-
struct flock lock;
85-
lock.l_type = F_WRLCK;
86-
lock.l_whence = SEEK_SET;
87-
lock.l_start = 0;
88-
lock.l_len = 0;
89-
if (fcntl(fd, F_SETLK, &lock) == -1) {
90-
reason = GetErrorReason();
91-
return false;
92-
}
69+
struct flock lock;
70+
lock.l_type = F_WRLCK;
71+
lock.l_whence = SEEK_SET;
72+
lock.l_start = 0;
73+
lock.l_len = 0;
74+
if (fcntl(fd, F_SETLK, &lock) == -1) {
75+
reason = GetErrorReason();
76+
return false;
9377
}
9478

9579
return true;

0 commit comments

Comments
 (0)