<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: monospace; font-size: 13px;" class="">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 style="font-family: monospace; font-size: 13px;" class="">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 style="font-family: monospace; font-size: 13px;" class="">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 style="font-family: monospace; font-size: 13px;" class=""> 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 style="font-family: monospace; font-size: 13px;" class=""><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 style="font-family: monospace; font-size: 13px;" class=""><span class="Apple-tab-span" 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 style="font-family: monospace;
font-size: 13px;" class="">} </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;"><br></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;">flag gets initialized with the following code </span><br></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 style="font-family: monospace; font-size: 13px;" class=""><br class="" style=""></span></span></div><div class="" style="background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""> { ngx_string("module1_directive"),</span></div><div class=""
style="background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""> NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,</span></div><div class="" style="background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""> ngx_conf_set_flag_slot,</span></div><div class="" style="background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""> NGX_HTTP_LOC_CONF_OFFSET,</span></div><div class="" style="background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""> 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 style="font-family: monospace; font-size: 13px;"
class=""> NULL },</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13px; font-family: monospace; font-style: normal; background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class=""><br></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13px; font-family: monospace; font-style: normal; background-color: transparent;"><span style="font-family: monospace; font-size: 13px;" class="">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 style="font-family: monospace; font-size: 13px;" class=""><br></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></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 style="font-family: monospace; font-size: 13px;" class=""><br></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 style="font-family: monospace; font-size: 13px;" class="">Hello!</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">On Tue, Jun 10, 2014 at 02:09:13AM +0800, Rv Rv wrote:</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> How do we access the
configuration of a an unrelated module in a </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> given module. This may be required for example to check if the </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> directives pertaining to module 2 were specified in location for </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> a particular server that has directives for module 1 in its </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> configuration.</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span
style="font-family: monospace; font-size: 13px;" class="">I don't think it's something you should do at postconfiguration - </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">location structure is complex and not easily accessible. There </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">are location configuration merge callbacks where you are expected </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">to work with location configs and, in particular, can use </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">ngx_http_conf_get_module_loc_conf() macro to access a </span><br style="font-family:
monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">configuration of other modules (note though, that order of modules </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">may be important in this case).</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">[...]</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">> I did not find any documentation on how the configuration is stored within nginx using these structs?</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;"
class=""><span style="font-family: monospace; font-size: 13px;" class="">It's under src/, in C language.</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">I would rather say it's not a part of the API, and you'd better </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">avoid using it directly.</span><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">-- </span><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">Maxim Dounin</span><br style="font-family: monospace; font-size: 13px;" class=""><a
href="http://nginx.org/" target="_blank" style="color: rgb(25, 106, 212); font-family: monospace; font-size: 13px;" class="">http://nginx.org/</a><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><br style="font-family: monospace; font-size: 13px;" class=""><span style="font-family: monospace; font-size: 13px;" class="">------------------------------</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 Monday, 9 June 2014 11:39 PM, Rv Rv <rvrv7575@yahoo.com> wrote:<br
class="" style=""> </font> </div> <br class="" style=""><br class="" style=""> <div class="" style=""><div id="yiv8631460072" 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="">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 class="" style=""></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;font-style:normal;background-color:transparent;" class="">From what I understand, code similar to this can be used </div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times,
serif;background-color:transparent;" class=""><span style="font-style:italic;" class="">/* Get http main configuration */</span></div><div style="background-color:transparent;" class=""><span style="font-style:italic;" class=""> cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; </span><br class="" style=""></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;font-style:normal;background-color:transparent;" class=""><span style="font-style:italic;" class="">/* Get the list of servers */</span></div><div style="color:rgb(0, 0, 0);font-size:16px;font-family:'times new roman', 'new york', times, serif;font-style:italic;background-color:transparent;" class=""><span style="font-style:italic;" class=""></span></div><div style="background-color:transparent;" class=""><span style="font-style:italic;" class=""> cscfp = cmcf->servers.elts;</span></div><div class=""
style=""><span style="font-style:italic;" class="">/* Iterate through the list */</span></div><div class="" style=""><div class="" style=""><span style="font-style:italic;" class=""> for (s = 0; s < cmcf->servers.nelts; s++) {</span></div><div class="" style=""> /* <span style="font-style:italic;" class="">Problem : how to get the configuration of module 2*/</span></div><div class="" style=""><div class="" style=""><span style="font-style:italic;" class=""> cscfp[s]->ctx->loc_conf[module2.ctx_index];-------------> does not yield the correct location struct of module 2</span></div><div class="" style=""><span style="font-style:italic;" class=""><br class="" style=""></span></div><div class="" style=""><span style="font-style:italic;" class="">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=""><div class="" style="font-style:italic;">typedef struct
{</div><div class="" style="font-style:italic;">.............</div><div class="" style=""><span style="font-style:italic;" class=""> </span><span class="" style="font-style:italic;white-space:pre;"> </span><span style="font-style:italic;" class="">/* server ctx */
ngx_http_conf_ctx_t *ctx;</span></div></span><span style="font-style:italic;" class=""> ............<br class="" style=""></span></div><div class="" style=""><span style="font-style:italic;" class=""><div class="" style="">} ngx_http_core_srv_conf_t;</div><div class="" style=""><br class="" style=""></div></span></div><div class="" style=""><br class="" style=""></div><div class="" style=""><span style="font-style:italic;" class=""><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 class="" style=""></div></span></div><div class="" style=""><br class="" style=""></div></div></div></div></div></div><br class=""
style=""><br class="" style=""></div> </div> </div> </div> </div></body></html>