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

void monitor_t::abort() is violating RAII principle #381

Open
lp35 opened this issue Jan 27, 2020 · 2 comments
Open

void monitor_t::abort() is violating RAII principle #381

lp35 opened this issue Jan 27, 2020 · 2 comments

Comments

@lp35
Copy link

lp35 commented Jan 27, 2020

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.

@lp35
Copy link
Author

lp35 commented Jan 27, 2020

(I can PR if needed)

@sigiesec
Copy link
Member

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?

This was referenced May 13, 2020
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