ignore glob no match error
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 54769fb..6efcd8b 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c
@@ -645,10 +645,18 @@ return NGX_CONF_ERROR; } + if (strpbrk((char *) file.data, "*?[") == NULL) { + + ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data); + + return ngx_conf_parse(cf, &file); + } + ngx_memzero(&gl, sizeof(ngx_glob_t)); gl.pattern = file.data; gl.log = cf->log; + gl.test = 1; if (ngx_open_glob(&gl) != NGX_OK) { ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c index a091b9b..7ee8cbd 100644 --- a/src/os/unix/ngx_files.c +++ b/src/os/unix/ngx_files.c
@@ -257,7 +257,15 @@ ngx_int_t ngx_open_glob(ngx_glob_t *gl) { - if (glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob) == 0) { + int n; + + n = glob((char *) gl->pattern, GLOB_NOSORT, NULL, &gl->pglob); + + if (n == 0) { + return NGX_OK; + } + + if (n == GLOB_NOMATCH && gl->test) { return NGX_OK; }
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h index 85dae3b..a223b34 100644 --- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h
@@ -154,10 +154,11 @@ typedef struct { - size_t n; - glob_t pglob; - u_char *pattern; - ngx_log_t *log; + size_t n; + glob_t pglob; + u_char *pattern; + ngx_log_t *log; + ngx_uint_t test; } ngx_glob_t;
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c index 9e5feba..7695198 100644 --- a/src/os/win32/ngx_files.c +++ b/src/os/win32/ngx_files.c
@@ -361,6 +361,12 @@ gl->dir = FindFirstFile((const char *) gl->pattern, &gl->finddata); if (gl->dir == INVALID_HANDLE_VALUE) { + + if (ngx_errno == ERROR_FILE_NOT_FOUND && gl->test) { + gl->no_match = 1; + return NGX_OK; + } + return NGX_ERROR; } @@ -394,6 +400,10 @@ size_t len; ngx_err_t err; + if (gl->no_match) { + return NGX_DONE; + } + if (gl->ready) { *name = gl->name; @@ -443,6 +453,10 @@ ngx_free(gl->name.data); } + if (gl->dir == INVALID_HANDLE_VALUE) { + return; + } + if (FindClose(gl->dir) == 0) { ngx_log_error(NGX_LOG_ALERT, gl->log, ngx_errno, "FindClose(%s) failed", gl->pattern);
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h index 799e0b0..5f92641 100644 --- a/src/os/win32/ngx_files.h +++ b/src/os/win32/ngx_files.h
@@ -184,7 +184,11 @@ typedef struct { HANDLE dir; WIN32_FIND_DATA finddata; - ngx_int_t ready; + + unsigned ready:1; + unsigned test:1; + unsigned no_match:1; + u_char *pattern; ngx_str_t name; size_t last;