Finalizer thread blocked if ZmqContext goes out of scope
rtanase opened this issue · 1 comments
rtanase commented
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();
fynman commented
add socket.Close() before context = null