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

Clean way to free Uring #3

Open
WJWH opened this issue Jul 9, 2020 · 3 comments
Open

Clean way to free Uring #3

WJWH opened this issue Jul 9, 2020 · 3 comments

Comments

@WJWH
Copy link
Contributor

WJWH commented Jul 9, 2020

Maybe I misunderstand how it works, but there does not seem to be a clean way to close the Uring from Haskell land. There is the uringFptr in the URing data structure that is a ForeignPtr HsURing coming from c_free_uring but I don't really understand how to use it.

@bgamari
Copy link
Owner

bgamari commented Jul 10, 2020

Indeed there is no explicit way to free a ring. The ForeignPtr will be finalized when the ring becomes unreachable.

We could in principle add an explicit finalization interface, but that then raises questions about when to do when a ring is prematurely finalized.

@WJWH
Copy link
Contributor Author

WJWH commented Jul 11, 2020

Aha, I hadn't really thought about the use-after-free implications. My intended use case was during the stopping of an IO manager, but I suppose that the finalizers of a ForeignPtr suffice for cleaning up when it's GC-ed. As I understand it, an IO manager would only really be closed when the program shuts down anyway. I'll add a note in the docs that manually closing the Uring is not required.

@bgamari
Copy link
Owner

bgamari commented Jul 11, 2020

Thanks!

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