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

Missing Send impl for Alpm? #42

Open
fosskers opened this issue Mar 17, 2024 · 4 comments
Open

Missing Send impl for Alpm? #42

fosskers opened this issue Mar 17, 2024 · 4 comments

Comments

@fosskers
Copy link
Contributor

Hi there. Between major versions 2 and 3, the Alpm type lost its Send implementation. This prevents it from being passed to other threads, even when wrapped in lock types like in Arc<Mutex<Alpm>>. Was this change intentional, or am I overlooking something?

Thanks,

Colin

@fosskers
Copy link
Contributor Author

For now, I have worked around this by tricking the compiler: https://github.com/fosskers/aura/blob/master/rust/r2d2-alpm/src/lib.rs#L35-L64

This works for my use cases. While indeed sharing a raw alpm::Alpm across threads does currently cause segfaults, using a connection pool as I'm doing works as intended.

@Morganamilo
Copy link
Member

I did this like 3 years ago (been waiting to release V3 for a long time) so my memory is a bit fuzzy.

I think I'd need to re reason if it's safe or not. I think it may be safe if the callbacks were also bounded by send.

@fosskers
Copy link
Contributor Author

fosskers commented Mar 18, 2024

The error messages were complaining a lot about the callbacks, but also about the NonNull that now wraps the inner alpm_handle_t.

Experimentally at least it seems to be safe not explode. Using a pool I'm able to have several open Alpm connections and use them with rayon, basically only for concurrent reads to the DB. I'm never calling anything requires &mut Alpm.

@fosskers
Copy link
Contributor Author

fosskers commented Mar 18, 2024

For now Aura is fixed with the workaround, so there's no rush (on my end) for Send to be provided directly.

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