[zeromq-dev] Problems with 2.0.6 poll using C++ api

gonzalo diethelm gdiethelm at dcv.cl
Fri Mar 19 12:17:08 CET 2010


> 2. Have a look at dispatcher.cpp, lines 146-154. The code there is
> called when socket is created. It checks whether there's another
socket
> belonging to the same thread and if so, it chooses to share the same
> app_thread_t object. Something probably goes wrong there. Can you
check
> it? Maybe current thread ID as returned by thread_t::id() is different
> even if called twice from the same thread? Maybe thread ID comparison
> function, thread_t::equal() is broken and returns false even if the
two
> thread IDs are the same?

I took a look at that code. The only thing I noticed is that it will
fill the app_threads array "backwards", from N-1, N-2, ..., to 0. But I
don't think that really matters.

I also thought it was weird to see the for statement using a !=
comparison. I would probably have written it like this, with a <:

  for (current = 0; current < app_threads.size (); current++) {...}

But that, also, doesn't make any difference.

Finally, I looked at thread_t::equal (). It compares the two thread ids
with ==; however, for non-Windows Oss, the thread ids are of type
pthread_t, and those objects should be compared with pthread_equal ().
Therefore, I would change line 46 in thread.cpp to this:

bool zmq::thread_t::equal (id_t id1_, id_t id2_)
{
#ifdef ZMQ_HAVE_WINDOWS
    return id1_ == id2_;
#else
    return pthread_equal (id1_, id2_);
#endif
}

This is non-tested (I am running on Windows here) and submitted
MIT-licensed, for whatever it is worth. Best regards.

-- 
Gonzalo Diethelm



----------------------------------------- 
Declaración de confidencialidad: Este Mensaje esta destinado para
el uso de la o las personas o entidades a quien ha sido dirigido y
puede contener información reservada y confidencial que no puede
ser divulgada, difundida, ni aprovechada en forma alguna. El uso no
autorizado de la información contenida en este correo podrá ser
sancionado de conformidad con la ley chilena. 
Si usted ha recibido este correo electrónico por error, le pedimos
eliminarlo junto con los archivos adjuntos y avisar inmediatamente
al remitente, respondiendo este mensaje. 

"Before printing this e-mail think if is really necesary".
Disclosure: This Message is to be used by the individual,
individuals or entities that it is addressed to and may include
private and confidential information that may not be disclosed,
made public nor used in any way at all. Unauthorized use of the
information in this electronic mail message may be subject to the
penalties set forth by Chilean law. 
If you have received this electronic mail message in error, we ask
you to destroy the message and its attached file(s) and to
immediately notify the sender by answering this message. 




More information about the zeromq-dev mailing list