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

Solution for using in DLL #34

Open
ik9999 opened this issue Mar 1, 2024 · 0 comments
Open

Solution for using in DLL #34

ik9999 opened this issue Mar 1, 2024 · 0 comments

Comments

@ik9999
Copy link

ik9999 commented Mar 1, 2024

I had a problem:
slog_async had been freezing execution of my windows dll because it had been getting stuck waiting for thread to finish with join() (even though the thread exists successfully). This had been happening while i was waiting for AsyncGuard to drop.

My solution was to add

                    while !join.is_finished() {
                        std::thread::sleep(std::time::Duration::from_millis(50));
                    }

above this line

async/lib.rs

Line 393 in c2040ac

join.join().map_err(|_| {

.
Not a beautiful solution, so i decided not to make a pull request, but its good enough for me. Maybe it will help someone.

Im using build_with_guard(). And then before dll unloading i manually drop async_guard. With this fix drop(async_guard) finishes successfully and doesnt get stuck.

Update:
Its still unsable (sometimes it still freezes). I had to remove

                    join.join().map_err(|err| {
                        println!("prev err: {:#?}", err);
                        io::Error::new(
                            io::ErrorKind::BrokenPipe,
                            "Logging thread worker join error",
                        )
                    })?;

at

async/lib.rs

Line 393 in c2040ac

join.join().map_err(|_| {

completely to make it working (replaced with above-mentioned while basically).

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

1 participant