Make cache private for each mount and enforce LRU eviction.#3
Conversation
|
Reviews in this chain: |
| .collect(); | ||
| let n_files = bodies.len(); | ||
|
|
||
| let handle = thread::spawn(move || { |
There was a problem hiding this comment.
We'd probably want to use async at this point (possibly Tokio, since it's the most popular, or some other runtime if there's some merit behind a particular one), but that's definitely out of scope of this PR
There was a problem hiding this comment.
This is just moved, I didn't add this in this PR. I think that would be bigger rewrite 🤷
| } | ||
| } | ||
|
|
||
| fn is_process_alive(pid: u32) -> bool { |
There was a problem hiding this comment.
Not that I've known it myself, but seems legit:
kill(pid, 0) returns -1 with errno == EPERM if the process exists but belongs to another user. The current check would treat that as "dead" and delete the directory. Should check errno != ESRCH instead:
fn is_process_alive(pid: u32) -> bool {
let ret = unsafe { libc::kill(pid as i32, 0) };
if ret == 0 {
return true;
}
// EPERM means process exists but we lack permission to signal it
std::io::Error::last_os_error().raw_os_error() != Some(libc::ESRCH)
}There was a problem hiding this comment.
fair, I mostly ignored this because in our cases that can never happen, but fine 🤷
erszcz
left a comment
There was a problem hiding this comment.
LGTM in general, but might be worth checking the is_process_alive details
64ee52f to
3b1aca2
Compare
No description provided.