I have some questions about contexts (zctx_new()), particularly how to
manage them properly.

According to the Guide, I should do one zctx_new() at the start of my
mainline code and one zctx_destroy() at the end.  This seems reasonable,
except when I look at the description for zthread_fork().  This is used to
create an attached thread, and "shadows" the context given at the time of
the fork.  The description ends with "Do not destroy the ctx, the thread
does this automatically when it ends."

I have an application that forks three processes (for listening and
responding to separate interfaces).  Should I be creating different
contexts for each of the threads (they are not sharing common sockets), or
should the interpretation of the above quote be "the *shadow* context is
deleted automatically when the thread ends?"

I'm running into some weird asserts when my program terminates (^C from the
command-line), and I'm wondering whether I'm deleting contexts that I
shouldn't be deleting.  There doesn't seem to be a zthread_join, so the
threads get terminated at random times w.r.t. one another.

I looked at filemq to try and get a feel for how this should be handled.
 Both fmq_client_new() and fmq_server_new() create contexts for themselves
before spawning their threads.  The track.c program creates both a client
and a server and its mainline never creates a context (or destroys one).

What am I missing?

Thanks,
--Scott
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to