the way of the module context can meet many requitments. But some others can&#39;t be implemented by the module way.<br>for example, <br>In the struct&quot;ngx_http_upstream_rr_peer_t&quot;, I want add a variable to count how many times I haved request this upstream.<br>
If there is a reserved pointer, I can use it point a struct I have defined in my module. But now,I must modify the source code and when I want to replace with a new version nginx, I have to re-modifiy the code.<br><br>ngx_http_request_t can expand datas with the module context, but other data struct can&#39;t use module conext?<br>
<br>thank you<br><br><div class="gmail_quote">2009/6/23 Maxim Dounin <span dir="ltr">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello!<br>
<div class="im"><br>
On Tue, Jun 23, 2009 at 06:05:19PM +0800, Chieu wrote:<br>
<br>
&gt; hi, developers<br>
&gt; Because of the modularity of nginx, I can extend the new function easily.<br>
&gt; But there are some requirements which need to modify the original source<br>
&gt; code.<br>
&gt; For example:<br>
&gt; I want to add a variable which records the count of requests sent to each<br>
&gt; upstream. And I must add a variable into the struct<br>
&gt; &quot;ngx_http_upstream_rr_peer_t&quot;, when round robin get the upstream ,the<br>
&gt; variable++ . This way, I shoud modify the source code of the upstream<br>
&gt; module.<br>
<br>
</div>You may easily write transparent upstream balancer module that<br>
does this (just counts and passes everything to the real<br>
balancer).  Without nginx code modifications.  It&#39;s not really<br>
efficient due to extra function calls, but it will work.<br>
<div class="im"><br>
&gt; I think if the struct &quot;ngx_http_upstream_rr_peer_t&quot; have a reserved<br>
&gt; pointer(void *), which reserved for others developing new modules.<br>
&gt; Totally, I think the modularity of nginx just resolved the expansibility of<br>
&gt; function. But if the I want to expand some import data like the struct<br>
&gt; &quot;ngx_http_request_t&quot;, I must modify the original source code. And if  some<br>
&gt; important struct adds a reserved pointer, I think the data of nginx will be<br>
&gt; easily be extend.<br>
<br>
</div>I don&#39;t really understand the question, but for any data you may<br>
use either your module context (every module has pointer to it&#39;s<br>
context stored in ngx_http_request_t) or variables (if you need<br>
something that survives internal redirects).<br>
<font color="#888888"><br>
Maxim Dounin<br>
<br>
</font></blockquote></div><br>