I managed to understand an important detail:

the problem arises from how I pass parameters to the child thread.

If I just pass a void pointer to the zmq context, all is fine.
If I pass a pointer to my struct (with explicit castings on both sides), the problems shows its head.

Now I don't know enough to understand this, I hope someone more knowledgeable can chime in.

Here are the two possibilities

working

void *zmq_cont_ptr = zmq_ctx_new();
pthread_create(&th_hndl_subber, NULL, th_subscriber, zmq_cont_ptr);



non working

typedef struct parameters{
    //Zmqcpp::Context * zmqcont;
    void * zmqcont;
    void (*callback) (std::string);
    std::string ip;
    int conntype;
    std::list<std::string> topics;
}parameters;

parameters myparams;

pthread_create(&th_hndl_subber, NULL, th_subscriber, (void *)&myparams);

void * th_subscriber(void * params)
{
    parameters *myparameters = (parameters *) params;


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

Reply via email to