File tree Expand file tree Collapse file tree 1 file changed +8
-24
lines changed Expand file tree Collapse file tree 1 file changed +8
-24
lines changed Original file line number Diff line number Diff 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-
6963bool 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 ;
You can’t perform that action at this time.
0 commit comments