Skip to content

Commit 0521d6c

Browse files
authored
Rollup merge of #134649 - SUPERCILEX:statx-remember, r=thomcc
Fix forgetting to save statx availability on success Looks like we forgot to save the statx state on success which means the first failure (common when checking if a file exists) will always require spending an invalid statx to confirm the failure is real. r? `@thomcc`
2 parents 9551808 + f19ba15 commit 0521d6c

File tree

1 file changed

+5
-1
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+5
-1
lines changed

Diff for: library/std/src/sys/pal/unix/fs.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ cfg_has_statx! {{
168168
) -> c_int
169169
}
170170

171-
if STATX_SAVED_STATE.load(Ordering::Relaxed) == STATX_STATE::Unavailable as u8 {
171+
let statx_availability = STATX_SAVED_STATE.load(Ordering::Relaxed);
172+
if statx_availability == STATX_STATE::Unavailable as u8 {
172173
return None;
173174
}
174175

@@ -200,6 +201,9 @@ cfg_has_statx! {{
200201
return None;
201202
}
202203
}
204+
if statx_availability == STATX_STATE::Unknown as u8 {
205+
STATX_SAVED_STATE.store(STATX_STATE::Present as u8, Ordering::Relaxed);
206+
}
203207

204208
// We cannot fill `stat64` exhaustively because of private padding fields.
205209
let mut stat: stat64 = mem::zeroed();

0 commit comments

Comments
 (0)