Skip to content

Commit 05fb206

Browse files
kwvgPastaPastaPasta
authored andcommitted
merge bitcoin#25898: remove WSL 1 workaround in fs
1 parent da5b433 commit 05fb206

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
@@ -62,36 +62,20 @@ FileLock::~FileLock()
6262
}
6363
}
6464

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

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

9781
return true;

0 commit comments

Comments
 (0)