openresty / echo-nginx-module

An Nginx module for bringing the power of "echo", "sleep", "time" and more to Nginx's config file
http://wiki.nginx.org/NginxHttpEchoModule
BSD 2-Clause "Simplified" License
1.17k stars 255 forks source link

Question of some directives's definition #25

Closed duhoobo closed 10 years ago

duhoobo commented 10 years ago

Learning your excellent code now, and running into the following question:

    { ngx_string("echo_after_body"),
      NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_ANY,
      ngx_http_echo_echo_after_body,
      NGX_HTTP_LOC_CONF_OFFSET,
      offsetof(ngx_http_echo_loc_conf_t, after_body_cmds),
      NULL },

    { ngx_string("echo_location_async"),
      NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_TAKE12,
      ngx_http_echo_echo_location_async,
      NGX_HTTP_LOC_CONF_OFFSET,
      0,  
      NULL },

I find echo_location[_async] and several other directives's definitions lack offset somehow. A wild guess: ngx_http_echo_helper parses them correctly just because handler_cmds is the first member of ngx_http_echo_loc_conf_t.

Is this done on purpose or what?

Thanks.

agentzh commented 10 years ago

@duhoobo We should have used offsetof(ngx_http_echo_loc_conf_t, handler_cmds) here instead of 0. It is just a happy accident that offsetof(ngx_http_echo_loc_conf_t, handler_cmds) happens to be 0 :)

Already fixed in master :)

agentzh commented 10 years ago

Thank you for the report!