diff options
author | Ruslan Ermilov <ru@nginx.com> | 2012-07-29 23:59:06 +0400 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2012-07-29 23:59:06 +0400 |
commit | 1c31039d1e0cc8d06fe5cd2b6ad727d3c1c25853 (patch) | |
tree | f7ae3c56e44b5bf45f6c3fe0ba3a2e24a705827c /src/core/ngx_conf_file.c | |
parent | 7f3a352e5a3aaf72a8fae7abfdb4cd9e0047aeb4 (diff) |
Improved diagnostics when a directive is specified in the wrong context.
Diffstat (limited to 'src/core/ngx_conf_file.c')
-rw-r--r-- | src/core/ngx_conf_file.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 01715af35..0aa659cd8 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -282,24 +282,16 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last) { char *rv; void *conf, **confp; - ngx_uint_t i, multi; + ngx_uint_t i, found; ngx_str_t *name; ngx_command_t *cmd; name = cf->args->elts; - multi = 0; + found = 0; for (i = 0; ngx_modules[i]; i++) { - /* look up the directive in the appropriate modules */ - - if (ngx_modules[i]->type != NGX_CONF_MODULE - && ngx_modules[i]->type != cf->module_type) - { - continue; - } - cmd = ngx_modules[i]->commands; if (cmd == NULL) { continue; @@ -315,16 +307,18 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last) continue; } + found = 1; + + if (ngx_modules[i]->type != NGX_CONF_MODULE + && ngx_modules[i]->type != cf->module_type) + { + continue; + } /* is the directive's location right ? */ if (!(cmd->type & cf->cmd_type)) { - if (cmd->type & NGX_CONF_MULTI) { - multi = 1; - continue; - } - - goto not_allowed; + continue; } if (!(cmd->type & NGX_CONF_BLOCK) && last != NGX_OK) { @@ -408,17 +402,16 @@ ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last) } } - if (multi == 0) { + if (found) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "unknown directive \"%s\"", name->data); + "\"%s\" directive is not allowed here", name->data); return NGX_ERROR; } -not_allowed: - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"%s\" directive is not allowed here", name->data); + "unknown directive \"%s\"", name->data); + return NGX_ERROR; invalid: |