mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-13 00:56:57 +02:00
fs: drop old WSL1 hack.
This commit is contained in:
16
src/fs.cpp
16
src/fs.cpp
@ -60,27 +60,12 @@ 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;
|
||||
@ -90,7 +75,6 @@ bool FileLock::TryLock()
|
||||
reason = GetErrorReason();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user