Skip to content

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

@lp35

Description

@lp35

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions