[zeromq-dev] Exiting a child thread

Cerizza, Giordano cerizza at nscl.msu.edu
Tue Apr 17 15:10:33 CEST 2018

I have the following problem: I have a source of messages connected to a proxy; the PULL/PUSH proxy reroutes the
messages via inproc to a multithreaded service that receives the messages and pushes them to a destination sink.
Here some pseudocode to help understand the streaming class:

void main(){
// definition of context (ctx_) and sockets for PULL/PUSH proxy (frontend,backend)
pthread worker[N]
for loop for number of thread
   pthread_create(&worker[i], NULL, worker_task, (void*)ctx_)
   zmq::proxy (*frontend, *backend, NULL);
} catch(...){
  // stuff

void* worker_task(void *arg){
zmq::context_t *context = (zmq::context_t*) arg;
// definition of the sockets to pull from (socket_from) and push to (socket_to)
// operations on messages (receive and send)
// exiting the worker_task

Observations: my system hangs before exiting the child thread. I tried to close the sockets (zmq_close) and destruct (zmq_term) the context for the child but nothing happens. How do I safely leave the thread and move on with my code i.e. close the sockets and destroy the context for the proxy, destruct the streaming class, and move to operate on the message sink?

Thanks in advance
Best wishes

Giordano Cerizza
Michigan State University
East Lansing, MI 48824-1321
cerizza at nscl.msu.edu<mailto:cerizza at nscl.msu.edu>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180417/0b89ff7b/attachment.htm>

More information about the zeromq-dev mailing list