This is a followup to my earlier post on 16 Feb 2018 regarding reactor shutdown
when using zactors. I did get one response (thanks Luca!) but I did not
describe the problem adequately, so here goes in the hopes that someone can
help me do it right.
timer_handler(zloop, timer_id, pipe) {
// passes msg from pipe to timer_thread
}
socket_handler(zloop, zsock, pipe) {
// passes msg from pipe to socket_thread
}
main() {
Create zactor “timer_thread”
Create zactor “socket_thread”
zloop_timer(loop, <stuff>, timer_handler, timer_thread as arg)
zloop_reader(loop, socket, socket_hander, socket_thread as arg)
while (!zsys_interrupted) {
if (zloop_start(loop) != 0)
break; //termination received
}
}
So when a message comes in over a socket, zloop calls the handler and it sends
it thru to the zactor. Similarly when the timer goes off it also sends data to
its thread. The problem I’m having is making the threads exit. Right now only
one exits at a time when I hit CTRL-C. I have to hit it 3 times to fully exit
the application. Each of the zactors is calling
int check_interrupt(zsock_t *pipe) {
int interrupt = 0;
char *msg = zstr_recv(pipe);
if (zsys_interrupted || (msg && !strcmp(msg, "$TERM")))
interrupt = -1;
free(msg);
return interrupt;
}
Thanks,
Joe
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev