| ... | @@ -2120,18 +2120,18 @@ pub fn dirOpenFileWtf16( | ... | @@ -2120,18 +2120,18 @@ pub fn dirOpenFileWtf16( |
| 2120 | .BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't | 2120 | .BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't |
| 2121 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, | 2121 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, |
| 2122 | .INVALID_PARAMETER => |err| return w.statusBug(err), | 2122 | .INVALID_PARAMETER => |err| return w.statusBug(err), |
| 2123 | .SHARING_VIOLATION => return error.AccessDenied, | 2123 | .SHARING_VIOLATION => { |
| 2124 | .ACCESS_DENIED => { | | |
| 2125 | // This occurs if the file attempting to be opened is a running | 2124 | // This occurs if the file attempting to be opened is a running |
| 2126 | // executable. However, there's a kernel bug: the error may be | 2125 | // executable. However, there's a kernel bug: the error may be |
| 2127 | // incorrectly returned for an indeterminate amount of time | 2126 | // incorrectly returned for an indeterminate amount of time |
| 2128 | // after an executable file is closed. Here we work around the | 2127 | // after an executable file is closed. Here we work around the |
| 2129 | // kernel bug with retry attempts. | 2128 | // kernel bug with retry attempts. |
| 2130 | if (attempt - max_attempts == 0) return error.AccessDenied; | 2129 | if (attempt - max_attempts == 0) return error.SharingViolation; |
| 2131 | _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); | 2130 | _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); |
| 2132 | attempt += 1; | 2131 | attempt += 1; |
| 2133 | continue; | 2132 | continue; |
| 2134 | }, | 2133 | }, |
| | 2134 | .ACCESS_DENIED => return error.AccessDenied, |
| 2135 | .PIPE_BUSY => return error.PipeBusy, | 2135 | .PIPE_BUSY => return error.PipeBusy, |
| 2136 | .PIPE_NOT_AVAILABLE => return error.NoDevice, | 2136 | .PIPE_NOT_AVAILABLE => return error.NoDevice, |
| 2137 | .OBJECT_PATH_SYNTAX_BAD => |err| return w.statusBug(err), | 2137 | .OBJECT_PATH_SYNTAX_BAD => |err| return w.statusBug(err), |
| ... | @@ -2146,7 +2146,7 @@ pub fn dirOpenFileWtf16( | ... | @@ -2146,7 +2146,7 @@ pub fn dirOpenFileWtf16( |
| 2146 | // finished with the deletion operation, and so this CreateFile | 2146 | // finished with the deletion operation, and so this CreateFile |
| 2147 | // call has failed. Here, we simulate the kernel bug being | 2147 | // call has failed. Here, we simulate the kernel bug being |
| 2148 | // fixed by sleeping and retrying until the error goes away. | 2148 | // fixed by sleeping and retrying until the error goes away. |
| 2149 | if (attempt - max_attempts == 0) return error.AccessDenied; | 2149 | if (attempt - max_attempts == 0) return error.SharingViolation; |
| 2150 | _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); | 2150 | _ = w.kernel32.SleepEx((@as(u32, 1) << attempt) >> 1, w.TRUE); |
| 2151 | attempt += 1; | 2151 | attempt += 1; |
| 2152 | continue; | 2152 | continue; |