cppzmq
cppzmq copied to clipboard
void monitor_t::abort() is violating RAII principle
Hi,
I run into a strange bug today, due to monitor_t.
To my understanding of the class, what init() does is reversed by abort() call.
abort() should then free the socket, to allow the zmq context to be freed.
In this case, abort should contains the following code:
if (socketPtr)
zmq_socket_monitor(socketPtr, NULL, 0);
socketPtr = NULL;
if (monitor_socket)
zmq_close(monitor_socket);
The socket cannot be closed until the destructor is called, that can be problematic for some use cases.
I guess that issue #185 is related to this bug.
EDIT: I think thix fix is not intended to be in abort() method. I suggest to create a new method, called close() that close properly the socket.
(I can PR if needed)
I am not sure if I understand the problem here completely. Shutting down monitoring right is rather tricky, unfortunately. I am currently investigating an issue in libzmq related to that as well. Could you share a test case that demonstrates the problem?