Unverified Commit 9808d727 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

fix trace file reloading (#69655)

### What?

reloads the trace file when it is re-created.
parent 52cc01df
...@@ -252,25 +252,23 @@ impl TraceReader { ...@@ -252,25 +252,23 @@ impl TraceReader {
println!("Initial read completed ({} MB)", total / (1024 * 1024)); println!("Initial read completed ({} MB)", total / (1024 * 1024));
} }
} }
thread::sleep(Duration::from_millis(100)); loop {
let Ok(end) = file.seek(SeekFrom::End(0)) else { // No more data to read, sleep for a while to wait for more data
return Some(true); thread::sleep(Duration::from_millis(100));
}; let Ok(mut real_file) = File::open(&self.path) else {
// No more data to read, sleep for a while to wait for more data
if end < pos {
// new file
return Some(true);
} else if end != pos {
// Seek to the same position. This will fail when the file was
// truncated.
let Ok(new_pos) = file.seek(SeekFrom::Start(pos)) else {
return Some(true); return Some(true);
}; };
if new_pos != pos { let Ok(end) = real_file.seek(SeekFrom::End(0)) else {
return Some(true);
};
if end < pos {
// new file
return Some(true); return Some(true);
} else if end != pos {
// file has more data
return None;
} }
} }
None
} }
fn wait_for_new_file(&self, file: &mut TraceFile) { fn wait_for_new_file(&self, file: &mut TraceFile) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment