Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Calling close on wrong thread should be avoided #16

Closed
lodejard opened this issue Jul 8, 2014 · 3 comments
Closed

Calling close on wrong thread should be avoided #16

lodejard opened this issue Jul 8, 2014 · 3 comments

Comments

@lodejard
Copy link
Contributor

lodejard commented Jul 8, 2014

That can happen when a safehandle is GC'ed - to work this will actually need to queue to the loop handle to actually finish releasing?

@ThatRendle
Copy link
Contributor

Anything doing anything to libuv needs to be executed on the loop thread or
you end up with AccessViolationExceptions all over the shop.

On Tuesday, 8 July 2014, Louis DeJardin [email protected] wrote:

That can happen when a safehandle is GC'ed - to work this will actually
need to queue to the loop handle to actually finish releasing?


Reply to this email directly or view it on GitHub
#16.

Mark Rendle
Founder, Zudio https://zud.io/

@ThatRendle
Copy link
Contributor

Don't know if it's any help, or even relevant, but I ended up writing some thread-marshaling code to distribute requests off the libuv loop thread and marshal responses back onto it, mostly here: https://github.com/markrendle/FluxUv/blob/master/FluxUv/RequestDispatcher.cs

and here: https://github.com/markrendle/FluxUv/blob/master/FluxUv%2FFluxServer.cs#L74-L97

Everything relating to the libuv loop, handles, allocated memory, anything has to be done on the loop thread, it seems.

@lodejard
Copy link
Contributor Author

lodejard commented Jul 8, 2014

Yep, exactly the same kind of thing. This particular bug is about marshalling back onto the loop thread in order to call uv_close when something like tcp safehandle is garbage collected. The gc happens on a random finalizer thread...

lodejard pushed a commit that referenced this issue Jul 8, 2014
All of the uv_* calls must be called on the original thread
the finalizer thread cleaning up safehandle classes needs
special handling

see #16
@lodejard lodejard added this to the 0.1-alpha3 milestone Jul 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants