Skip to content

Commit

Permalink
Unrolled build for rust-lang#134649
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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`
  • Loading branch information
rust-timer authored Dec 27, 2024
2 parents 917bfa7 + f19ba15 commit 81401c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion library/std/src/sys/pal/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ cfg_has_statx! {{
) -> c_int
}

if STATX_SAVED_STATE.load(Ordering::Relaxed) == STATX_STATE::Unavailable as u8 {
let statx_availability = STATX_SAVED_STATE.load(Ordering::Relaxed);
if statx_availability == STATX_STATE::Unavailable as u8 {
return None;
}

Expand Down Expand Up @@ -200,6 +201,9 @@ cfg_has_statx! {{
return None;
}
}
if statx_availability == STATX_STATE::Unknown as u8 {
STATX_SAVED_STATE.store(STATX_STATE::Present as u8, Ordering::Relaxed);
}

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

0 comments on commit 81401c6

Please sign in to comment.