<p>Thanks for the feedback! Everything works smoothly now.</p>
<p>Mike Gagnon</p>
<div class="gmail_quote">On Apr 11, 2012 2:41 AM, "Maxim Dounin" <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<br>
On Tue, Apr 10, 2012 at 07:50:43PM -0700, Mike Gagnon wrote:<br>
<br>
> Hello,<br>
><br>
> I am developing a load-balancing module for nginx. I have noticed that<br>
> when a peer fails (say because the connection was reset by the peer)<br>
> the r->upstream->peer.free function is called multiple times on the<br>
> same peer connection: the first time with state == NGX_PEER_FAILED<br>
> set, and the second time with state == 0.<br>
><br>
> What is the purpose of calling peer.free multiple times?<br>
<br>
There is no real reason, it's more or less bug.  It's not yet<br>
fixed as it doesn't cause any problems with vanilla balancer<br>
modules (well, actually there is a workaround in upstream<br>
keepalive, though it's mostly result of the fact it was developed<br>
as a separate module).  We'll likely fix this somewhere in<br>
1.3.x.<br>
<br>
> Is there a<br>
> recommended way to tell if a call to peer.free is the first call (for<br>
> that peer connection)? Or to tell if it is the last call (for that<br>
> peer connection)?<br>
><br>
> This issue is important for the correctness of my code.<br>
<br>
For now I would recommend doing similar thing as upstream<br>
keepalive does: remember 1st free() call in an internal data and<br>
ignore subsequent calls.<br>
<br>
Maxim Dounin<br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div>