[zeromq-dev] Exiting a child thread
Cerizza, Giordano
cerizza at nscl.msu.edu
Wed Apr 18 00:22:01 CEST 2018
Dear Luca,
It still hangs. Am I doing something conceptually wrong? If needed, I can post my full streaming class for suggestions/comments.
Thanks
Giordano
On Apr 17, 2018, at 6:15 PM, Luca Boccassi <luca.boccassi at gmail.com<mailto:luca.boccassi at gmail.com>> wrote:
On Tue, 2018-04-17 at 13:10 +0000, Cerizza, Giordano wrote:
Hi,
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_)
try{
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
pthead_exit(NULL);
}
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
Do not destroy the context, it's global.
Just close the socket.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20180417/43f43703/attachment.htm>
More information about the zeromq-dev
mailing list