<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div class="" style=""><span class="" style=""><span style="font-family: Arial; font-size: 16px;" class="">Hello Maxim</span></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 16px; font-family: Arial; font-style: normal; background-color: transparent;"><span class="" style=""><span style="font-family: Arial; font-size: 16px;" class="">Thanks for the response.</span></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 16px; font-family: Arial; font-style: normal; background-color: transparent;"><span class="" style=""><span style="font-family: Arial; font-size: 16px;" class="">>></span></span><span style="font-size: 12pt;" class="">As previously suggested, you should consider using merge callbacks</span></div><span class="" style="font-family: Arial;">>>to validate configuration
 instead.</span><div><br></div><div>The requirement is *not* to validate the configuration. The requirement is to find the final value set by one of the directives once the configuration has been parsed. e..g lets say we have a directive my_set_flag that sets a value to 0 or 1.</div><div><br></div><div>So if in configuration we have </div><div>location \ {</div><div>my_set_flag 0;</div><div>---</div><div>my_set_flag 1;</div><div>---</div><div>my_set_flag 0;</div><div>}</div><div><br></div><div>then the merge callback will be called thrice for each invocation of the directive. Let's assume the logic is to set a variable with whatever the value of the directive was. So once parsing completes, the value of the variable should be 0.</div><div><br></div><div>I can get this value during request processing. However, I cannot get this value *after* the parsing of the configuration has completed.  What is the nginx recommended way to get this value. As
 noted in earlier post, I am not seeing the correct values in post configuration - and so perhaps that is not the right way.</div><div><br></div><div>Thanks for your continued inputs</div><div><br class="" style="clear: both;"><div class="" style="color: rgb(0, 0, 0); font-size: 16px; font-family: Arial; font-style: normal; background-color: transparent;"><span class="" style=""><span style="font-family: Arial; font-size: 16px;" class="">Hello!</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">On Thu, Jun 12, 2014 at 01:46:58PM +0800, Rv Rv wrote:</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">[...]</span><br style="clear: both;
 font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> In the post configuration, I see that flag is not properly set</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> but somestring is. Flag is properly set during request</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> processing though.</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> Are the values set during processing of a directive in location</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">>
 struct guaranteed to be set by the time post configuration is</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> executed?</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> When is the time that one can check for the values set during</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> configuration. I need to test these values to ensure that they</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">> are sane when nginx is executed with -t option</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;"
 class=""><span style="font-family: Arial; font-size: 16px;" class="">Again: there are lots of location configurations, and by trying to</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">access them at postconfiguration callback you are likely checking</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">a wrong one. Note that even a simple config with a single</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">location in a single server{} block, like this:</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">http { server { location { ...
 } } }</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">has 3 location configurations for each http module.</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">As previously suggested, you should consider using merge callbacks</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">to validate configuration instead.</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">--</span><br style="clear: both;
 font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">Maxim Dounin</span><br style="clear: both; font-family: Arial; font-size: medium;" class=""><span style="font-family: Arial; font-size: 16px;" class="">http://nginx.org/</span><br class="" style=""></span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;" class=""> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;" class=""> <div dir="ltr" class="" style=""> <font size="2" face="Arial" class="" style=""> On Thursday, 12 June 2014 11:16 AM, Rv Rv <rvrv7575@yahoo.com> wrote:<br class="" style=""> </font> </div>  <br class="" style=""><br class="" style=""> <div class="" style=""><div id="yiv9947023585" class="" style=""><div class="" style=""><div
 style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;" class=""><div class="" style=""><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;">Hello Maxim</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;">Thanks for your response. Here is a related query.</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;">Say in module 1 I have a</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class=""
 style="font-family:monospace;font-size:13px;"> typedef struct  {</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;"><span class="" style="white-space:pre;">       </span>int flag;</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;"><span class="" style="white-space:pre;"> </span>ngx_str somestring;</span></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;">} </span></span>module1;</div><div class="" style="color:rgb(0, 0,
 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span style="background-color:transparent;" class=""><br clear="none" class="" style=""></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span style="background-color:transparent;" class="">flag gets initialized with the following code </span><br clear="none" class="" style=""></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style=""></span></span></div><div class="" style="background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">    { ngx_string("module1_directive"),</span></div><div class="" style="background-color:transparent;"><span
 class="" style="font-family:monospace;font-size:13px;">      NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,</span></div><div class="" style="background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">      ngx_conf_set_flag_slot,</span></div><div class="" style="background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">      NGX_HTTP_LOC_CONF_OFFSET,</span></div><div class="" style="background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">      offsetof(module1,configured),</span></div><div class="" style="background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;"></span></span></div><div class="" style="background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">      NULL },</span></div><div class=""
 style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style=""></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;">somestring gets iniitialized with a handler written in the module (i.e  not ngx_conf_set_flag_slot or any inbuilt handler).</span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style=""></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;">In the
 post configuration, I see that flag is not properly set but somestring is. Flag is properly set during request processing though.</div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;">Are the values set during processing of a directive in location struct guaranteed to be set by the time post configuration is executed?</div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;">When is the time that one can check for the values set during configuration. I need to test these values to ensure that they are sane when nginx is executed with -t option</div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><br clear="none" class="" style=""></div><div class="" style="color:rgb(0, 0,
 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;">Thanks</div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style=""></span></div><div class="" style="color:rgb(0, 0, 0);font-size:13px;font-family:monospace;font-style:normal;background-color:transparent;"><span class="" style=""><span class="" style="font-family:monospace;font-size:13px;">Hello!</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">On Tue, Jun 10, 2014 at 02:09:13AM +0800, Rv Rv wrote:</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class=""
 style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> How do we access the
 configuration of a an unrelated module in a </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> given module. This may be required for example to check if the </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> directives pertaining to module 2 were specified in location for </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> a particular server that has directives for module 1 in its </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> configuration.</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class=""
 style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">I don't think it's something you should do at postconfiguration - </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">location structure is complex and not easily accessible.  There </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">are location configuration merge callbacks where you are expected </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">to work with location configs and, in particular, can use </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class=""
 style="font-family:monospace;font-size:13px;">ngx_http_conf_get_module_loc_conf() macro to access a </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">configuration of other modules (note though, that order of modules </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">may be important in this case).</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">[...]</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">> I did not find any documentation on how the
 configuration is stored within nginx using these structs?</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">It's under src/, in C language.</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">I would rather say it's not a part of the API, and you'd better </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">avoid using it directly.</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class=""
 style="font-family:monospace;font-size:13px;">-- </span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">Maxim Dounin</span><br clear="none" class="" style="font-family:monospace;font-size:13px;"><a rel="nofollow" shape="rect" class="" target="_blank" href="http://nginx.org/" style="color:rgb(25, 106, 212);font-family:monospace;font-size:13px;">http://nginx.org/</a><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><br clear="none" class="" style="font-family:monospace;font-size:13px;"><span class="" style="font-family:monospace;font-size:13px;">------------------------------</span><br clear="none" class="" style=""></span></div> <div class="" style=""><br clear="none" class="" style=""><br clear="none"
 class="" style=""></div><div class="" id="yiv9947023585yqt40424" style=""><div class="" style="display:block;"> <div class="" style="font-family:times new roman, new york, times, serif;font-size:12pt;"> <div class="" style="font-family:times new roman, new york, times, serif;font-size:12pt;"> <div class="" dir="ltr" style=""> <font class="" size="2" face="Arial" style=""> On Monday, 9 June 2014 11:39 PM, Rv Rv <rvrv7575@yahoo.com> wrote:<br clear="none" class="" style=""> </font> </div>  <br clear="none" class="" style=""><br clear="none" class="" style=""> <div class="" style=""><div class="" id="yiv9947023585" style=""><div class="" style=""><div class="" style="color:#000;background-color:#fff;font-family:times new roman, new york, times, serif;font-size:12pt;"><div class="" style="">How do we access the configuration of a an unrelated module in a given module. This may be required for example to check if the directives pertaining to module 2
 were specified in location for a particular server that has directives for module 1 in its configuration.</div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;font-style:normal;background-color:transparent;">From what I understand, code similar to this can be used </div><div class="" style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;background-color:transparent;"><span class="" style="font-style:italic;">/* Get http main configuration */</span></div><div class="" style="background-color:transparent;"><span class="" style="font-style:italic;">    cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; </span><br clear="none" class="" style=""></div><div class="" style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times,
 serif;font-style:normal;background-color:transparent;"><span class="" style="font-style:italic;">/* Get the list of servers */</span></div><div class="" style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;font-style:italic;background-color:transparent;"><span class="" style="font-style:italic;"></span></div><div class="" style="background-color:transparent;"><span class="" style="font-style:italic;">    cscfp = cmcf->servers.elts;</span></div><div class="" style=""><span class="" style="font-style:italic;">/* Iterate through the list */</span></div><div class="" style=""><div class="" style=""><span class="" style="font-style:italic;">    for (s = 0; s < cmcf->servers.nelts; s++) {</span></div><div class="" style="">  /* <span class="" style="font-style:italic;">Problem : how to get the configuration of module 2*/</span></div><div class="" style=""><div class=""
 style=""><span class="" style="font-style:italic;">                  cscfp[s]->ctx->loc_conf[module2.ctx_index];-------------> does not yield the correct location struct of module 2</span></div><div class="" style=""><span class="" style="font-style:italic;"><br clear="none" class="" style=""></span></div><div class="" style=""><span class="" style="font-style:italic;">I did not find any documentation on how the configuration is stored within nginx using these
 structs </span></div><div class="" style=""><span class="" style=""></span><div class="" style="font-style:italic;">typedef struct
 {</div><div class="" style="font-style:italic;">.............</div><div class="" style=""><span class="" style="font-style:italic;"> </span><span class="" style="font-style:italic;white-space:pre;">  </span><span class="" style="font-style:italic;">/* server ctx */
    ngx_http_conf_ctx_t        *ctx;</span></div><span class="" style="font-style:italic;"> ............<br clear="none" class="" style=""></span></div><div class="" style=""><span class="" style="font-style:italic;"></span><div class="" style="">} ngx_http_core_srv_conf_t;</div><div class="" style=""><br clear="none" class="" style=""></div></div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style=""><span class="" style="font-style:italic;"></span><div class="" style="">typedef struct {</div><div class="" style="">    void        **main_conf;</div><div class="" style="">    void        **srv_conf;</div><div class="" style="">    void        **loc_conf;</div><div class="" style="">} ngx_http_conf_ctx_t;</div><div class="" style=""><br clear="none" class="" style=""></div></div><div class="" style=""><br clear="none" class=""
 style=""></div></div></div></div></div></div><br clear="none" class="" style=""><br clear="none" class="" style=""></div>  </div> </div>  </div></div> </div></div></div><br class="" style=""><br class="" style=""></div>  </div> </div>  </div> </div></div></body></html>