[zeromq-dev] czmq zloop proper shut down of zactors
Michal Vyskocil
michal.vyskocil at gmail.com
Thu Mar 8 10:38:34 CET 2018
Hi Joe,
can you post minimal reproducer somewhere? I tried to spot the problem, but
without having working example it's hard.
Bye
Michal
On Wed, Mar 7, 2018 at 10:46 PM, Georger, Joseph <
joseph.georger at stresearch.com> wrote:
> 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
> zeromq-dev at lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
--
best regards
Michal Vyskocil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180308/652ee999/attachment.htm>
More information about the zeromq-dev
mailing list