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

Monitor in separate thread doesn't terminate on abort() call #185

Open
CMun opened this issue Feb 22, 2018 · 3 comments
Open

Monitor in separate thread doesn't terminate on abort() call #185

CMun opened this issue Feb 22, 2018 · 3 comments

Comments

@CMun
Copy link

CMun commented Feb 22, 2018

Hello,

due to changes of zmq.hpp from 4.2.1 to 4.2.2, calling abort on a monitor object running in a separate thread doesn't end the monitor taks.

The problem is, that monitor loops unconditionally and doesn't check the check_event return value:

void monitor(socket_t &socket, const char *addr_, int events = ZMQ_EVENT_ALL)
{
  init (socket, addr_, events) ;
  while(true)
  {
    check_event(-1) ;
   }
}

Furhter on, within check_event, ETERM is not necessarily set, so you might get an violated assertion there.

Is this intended? Alternatively, what is the recommended way of terminating an monitor object in a separate thread on program end?

@definename
Copy link

definename commented Jul 27, 2018

Hi all,
Is there progress with this issue?

@Bates0000
Copy link

顺序问题,在Linux上顺序应该
socket.close;
context.close;
monitor thread end(monitor_t will throw an exception)

@gummif
Copy link
Member

gummif commented Sep 23, 2022

No this has not been fixed. The best way is probably not call that constructor and write you own run function for now (until someone writes a pull request).

monitor_t mon;
mon.init(socket, addr, events);
while (true) {
    if (!mon.check_event(-1) && zmq_errno() == ETERM) // or something else
        break;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants