Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Racy file write #2

Open
alion02 opened this issue Mar 31, 2022 · 2 comments
Open

Racy file write #2

alion02 opened this issue Mar 31, 2022 · 2 comments

Comments

@alion02
Copy link
Contributor

alion02 commented Mar 31, 2022

tak/playtak/src/main.rs

Lines 90 to 93 in c3f0fe9

// create analysis file
if let Ok(mut file) = File::create(format!("analysis_{}.ptn", sys_time())) {
file.write_all(player.get_analysis().to_ptn().as_bytes()).unwrap();
}

These lines are not guaranteed to run -- once the main thread ends, all background threads are eligible to be killed immediately.

@ViliamVadocz
Copy link
Owner

The write now happens in a synchronous thread. Is this still an issue? Please confirm and close if not.

@alion02
Copy link
Contributor Author

alion02 commented Apr 18, 2022

This was and still is on a synchronous background thread. You should .join() that thread to make sure it terminates before the main thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants