Ok. Finally I could work it out, so thanks anyway!<br><br>Here is my small contribution to nginx, it is not much, but it is something.<br><br><a href="https://github.com/xetorthio/nginx-upstream-idempotent">https://github.com/xetorthio/nginx-upstream-idempotent</a><br>
<br>Thanks everyone for your help, and if you have time and find something weired in the code, let me know!<br><br>Jonathan<br><br><div class="gmail_quote">On Tue, May 10, 2011 at 11:48 AM, Jonathan Leibiusky <span dir="ltr">&lt;<a href="mailto:ionathan@gmail.com">ionathan@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Right, that is why after digging for a while I realized I wan&#39;t doing it the right way.<br>Now I wrote a module that will hook into the upstream logic and will set all the callbacks to the round-robin callbacks. Only the the peer.free callback will call the original round-robin callback and after that will do something like:<div class="im">
<br>
<br>if (r-&gt;method == NGX_HTTP_POST) {<br></div>  pc-&gt;retries = 0;<br>
}<br><br>by setting retires = 0 I think nginx won&#39;t retry and will fail and I will be using round-robin logic for all the rest.<br><br>My only problem is that in the peer.free callback I don&#39;t have access to the request struct, so I don&#39;t know is the request&#39;s method. So now I am not sure if the approach is the right one.<br>

<br>Any thoughts on this?<div><div></div><div class="h5"><br>

<br><div class="gmail_quote">On Tue, May 10, 2011 at 11:32 AM, Piotr Sikora <span dir="ltr">&lt;<a href="mailto:piotr.sikora@frickle.com" target="_blank">piotr.sikora@frickle.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi,<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2. Any good advice on how I should do it? I was thinking on adding the validation somewhere in ngx_http_upstream_test_next (ngx_http_upstream.c), something like:<br>
if (r-&gt;method == NGX_HTTP_POST) {<br>
  return NGX_DECLINED;<br>
}<br>
</blockquote>
<br></div>
Keep in mind that you should decline sending request to another backend, only if you already sent it upstream. There is a bunch of errors (bad gateway, connection timeout, etc) which could lead to the code path in question, for which you should still send request to another backend.<br>


<br>
Best regards,<br><font color="#888888">
Piotr Sikora &lt; <a href="mailto:piotr.sikora@frickle.com" target="_blank">piotr.sikora@frickle.com</a> &gt;</font><div><div></div><div><br>
<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>