clrzmq icon indicating copy to clipboard operation
clrzmq copied to clipboard

Finalizer thread blocked if ZmqContext goes out of scope

Open rtanase opened this issue 9 years ago • 1 comments

Hi,

If we're not careful to dispose the ZmqSockets created and the ZmqContext goes out of scope, the finalizer thread is stuck forever. The documentation says that we're supposed to use a non-default Linger setting to make sure sockets would not stay blocked, but even with that option I'm still unable to avoid the blocking on the finalizer.

A simple repro is here:

var context = ZmqContext.Create(); var socket = context.CreateSocket(SocketType.PUB); socket.Identity = Guid.NewGuid().ToByteArray(); socket.Linger = TimeSpan.FromSeconds(1); socket.TcpKeepalive = TcpKeepaliveBehaviour.Enable; context = null; GC.Collect(); GC.WaitForPendingFinalizers();

rtanase avatar Apr 14 '15 21:04 rtanase

add socket.Close() before context = null

fynman avatar Oct 05 '15 19:10 fynman