handle race condition
(in remove_unused_shm_work_dirs)
This commit is contained in:
parent
a5ae4c13e1
commit
2e45754e27
@ -491,19 +491,34 @@ impl QemuProcess {
|
|||||||
path.push("lock");
|
path.push("lock");
|
||||||
if path.exists(){
|
if path.exists(){
|
||||||
|
|
||||||
let file_lock = OpenOptions::new()
|
let file_lock = match OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.open(&path)
|
.open(&path){
|
||||||
.expect("couldn't open shm work dir lock file");
|
Err(x) => {
|
||||||
|
println!("Warning: {}", x);
|
||||||
|
Err(x)
|
||||||
|
},
|
||||||
|
x => {
|
||||||
|
x
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
path.pop();
|
if file_lock.is_ok(){
|
||||||
match file_lock.try_lock_exclusive(){
|
path.pop();
|
||||||
Ok(_) => {
|
|
||||||
if path.starts_with("/dev/shm/") {
|
match file_lock.unwrap().try_lock_exclusive(){
|
||||||
fs::remove_dir_all(path).unwrap();
|
Ok(_) => {
|
||||||
}
|
if path.starts_with("/dev/shm/") {
|
||||||
},
|
match fs::remove_dir_all(path){
|
||||||
Err(_) => {},
|
Err(x) => {
|
||||||
|
println!("Warning: {}", x);
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(_) => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user