[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zeromq-dev
Subject:    Re: [zeromq-dev] =?utf-8?q?What_are_the_=E2=80=9Cserious_caveats?= =?utf-8?b?4oCdIHdpdGggWk1RX0ZEPw=
From:       Doron Somech <somdoron () gmail ! com>
Date:       2016-05-24 6:48:49
Message-ID: CAB814uF8Kk5ju8ui9dRFHNZ9ZmRFTd-hUNCxjgeEjbufs1F3fQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Only if you are using thread safe sockets. You can save a call by with just
calling with ZMQ_NOBLOCK (no need for ZMQ_EVENTS). Then you don't need to
worry about race condition.
On May 24, 2016 08:22, "Huttunen, Kalle (GE Healthcare)" <
Kalle.Huttunen@ge.com> wrote:

> > after your call to zmq_recv(), but before your call to select() / poll()
>
>
>
> Are you talking about the way to receive messages when the ZMQ_FD signals?
> Basically I currently have the following code called when the ZMQ_FD
> becomes readable (in pseudocode):
>
>
>
> while ZMQ_EVENTS has ZMQ_POLLIN bit set
>
> {
>
>     receive message from socket;
>
>     process message;
>
> }
>
>
>
> Is there a potential race condition here?
>
>
>
> Thanks,
>
> --
>
> Kalle Huttunen
>
>
>
> *From:* zeromq-dev [mailto:zeromq-dev-bounces@lists.zeromq.org] *On
> Behalf Of *Dave Lambley
> *Sent:* 23. toukokuuta 2016 19:08
> *To:* ZeroMQ development list
> *Subject:* EXT: Re: [zeromq-dev] What are the "serious caveats" with
> ZMQ_FD?
>
>
>
> On 23 May 2016 at 10:23, Huttunen, Kalle (GE Healthcare) <
> Kalle.Huttunen@ge.com> wrote:
>
> It seems that sending on the socket makes the ZMQ_FD readable. That in
> turn triggers the calling of the code where I check ZMQ_EVENTS and receive
> everything from the socket. This way I end up checking ZMQ_EVENTS after
> each send.
>
> Is the ZMQ_FD becoming readable when sending on the socket something that
> can be relied on?
>
>
>
> I believe you have a race condition. If a message arrives after your call
> to zmq_recv(), but before your call to select() / poll(), it will block
> despite there being a message ready.
>
> If you can tolerate messages being delayed, there is an simple workaround
> in which you call zmq_recv() periodically. We have code doing this by
> specifying a timeout in the select() call.
>
> Dave
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>

[Attachment #5 (text/html)]

<p dir="ltr">Only if you are using thread safe sockets. You can save a call by with \
just calling with ZMQ_NOBLOCK (no need for ZMQ_EVENTS). Then you don&#39;t need to \
worry about race condition.</p> <div class="gmail_quote">On May 24, 2016 08:22, \
&quot;Huttunen, Kalle (GE Healthcare)&quot; &lt;<a \
href="mailto:Kalle.Huttunen@ge.com">Kalle.Huttunen@ge.com</a>&gt; wrote:<br \
type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="FI" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">&gt; \
after your call to zmq_recv(), but before your call to select() / \
poll()<u></u><u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Are \
you talking about the way to receive messages when the ZMQ_FD signals? Basically I \
currently have the following code called when the ZMQ_FD  becomes readable (in \
pseudocode):<u></u><u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">while \
ZMQ_EVENTS has ZMQ_POLLIN bit set<u></u><u></u></span></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">{<u></u><u></u></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> \
receive message from socket;<u></u><u></u></span></p> <p class="MsoNormal"><span \
lang="EN-US" style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"> \
process message;<u></u><u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">}<u></u><u></u></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Is \
there a potential race condition here?<u></u><u></u></span></p> <p \
class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> \
<u></u></span></p> <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Thanks,<u></u><u></u></span></p>
 <p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">--
 <u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Kalle \
Huttunen<u></u><u></u></span></p> <p class="MsoNormal"><span lang="EN-US"><u></u>  \
<u></u></span></p> <p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span \
lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> \
zeromq-dev [mailto:<a href="mailto:zeromq-dev-bounces@lists.zeromq.org" \
target="_blank">zeromq-dev-bounces@lists.zeromq.org</a>] <b>On Behalf Of </b>Dave \
Lambley<br> <b>Sent:</b> 23. toukokuuta 2016 19:08<br>
<b>To:</b> ZeroMQ development list<br>
<b>Subject:</b> EXT: Re: [zeromq-dev] What are the "serious caveats" with \
ZMQ_FD?<u></u><u></u></span></p> <p class="MsoNormal"><u></u>  <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">On 23 May 2016 at 10:23, Huttunen, Kalle (GE Healthcare) &lt;<a \
href="mailto:Kalle.Huttunen@ge.com" target="_blank">Kalle.Huttunen@ge.com</a>&gt; \
wrote:<u></u><u></u></p> <p class="MsoNormal">It seems that sending on the socket \
makes the ZMQ_FD readable. That in turn triggers the calling of the code where I \
check ZMQ_EVENTS and receive everything from the socket. This way I end up checking \
ZMQ_EVENTS after each send.<br> <br>
Is the ZMQ_FD becoming readable when sending on the socket something that can be \
relied on?<u></u><u></u></p> <div>
<p class="MsoNormal"><u></u>  <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I believe you have a race \
condition. If a message arrives after your call to zmq_recv(), but before your call \
to select() / poll(), it will block despite there being a message \
ready.<u></u><u></u></p> </div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">If you can tolerate messages being \
delayed, there is an simple workaround in which you call zmq_recv() periodically. We \
have code doing this by specifying a timeout in the select() call.<u></u><u></u></p> \
</div> <div>
<p class="MsoNormal">Dave<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">  <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>

<br>_______________________________________________<br>
zeromq-dev mailing list<br>
<a href="mailto:zeromq-dev@lists.zeromq.org">zeromq-dev@lists.zeromq.org</a><br>
<a href="http://lists.zeromq.org/mailman/listinfo/zeromq-dev" rel="noreferrer" \
target="_blank">http://lists.zeromq.org/mailman/listinfo/zeromq-dev</a><br></blockquote></div>




_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic