aboutsummaryrefslogtreecommitdiff
path: root/src/fs.cpp
diff options
context:
space:
mode:
authorsinetek <pitwuu@gmail.com>2022-08-26 17:45:54 +0200
committersinetek <pitwuu@gmail.com>2022-09-09 22:07:17 +0200
commit5669afb80e350027705dc378d2ab16232567511a (patch)
tree8b5cf9929139289cc14d887e7ca68bc5cba562ad /src/fs.cpp
parentef5bb742f0f57d144db480ad04304ab64474ee1a (diff)
fs: drop old WSL1 hack.
Diffstat (limited to 'src/fs.cpp')
-rw-r--r--src/fs.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/fs.cpp b/src/fs.cpp
index 74b167e313..bfc95879f5 100644
--- a/src/fs.cpp
+++ b/src/fs.cpp
@@ -60,36 +60,20 @@ FileLock::~FileLock()
}
}
-static bool IsWSL()
-{
- struct utsname uname_data;
- return uname(&uname_data) == 0 && std::string(uname_data.version).find("Microsoft") != std::string::npos;
-}
-
bool FileLock::TryLock()
{
if (fd == -1) {
return false;
}
- // Exclusive file locking is broken on WSL using fcntl (issue #18622)
- // This workaround can be removed once the bug on WSL is fixed
- static const bool is_wsl = IsWSL();
- if (is_wsl) {
- if (flock(fd, LOCK_EX | LOCK_NB) == -1) {
- reason = GetErrorReason();
- return false;
- }
- } else {
- struct flock lock;
- lock.l_type = F_WRLCK;
- lock.l_whence = SEEK_SET;
- lock.l_start = 0;
- lock.l_len = 0;
- if (fcntl(fd, F_SETLK, &lock) == -1) {
- reason = GetErrorReason();
- return false;
- }
+ struct flock lock;
+ lock.l_type = F_WRLCK;
+ lock.l_whence = SEEK_SET;
+ lock.l_start = 0;
+ lock.l_len = 0;
+ if (fcntl(fd, F_SETLK, &lock) == -1) {
+ reason = GetErrorReason();
+ return false;
}
return true;