summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-06-07 12:08:44 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-06-07 12:08:44 +0000
commit9d4085af44e8eb9c18dbaa017b6deb2bb11644a2 (patch)
tree58e5c57912ce874cd1e43e7ca25e6fa96d8a6999
parent400683ac9102ee18564bb6eff0037e710fb48d9f (diff)
downloadnginx-9d4085af44e8eb9c18dbaa017b6deb2bb11644a2.tar.gz
nginx-9d4085af44e8eb9c18dbaa017b6deb2bb11644a2.tar.bz2
merge r3498, r3499:
opening files fixes: *) use non-blocking open() not to hang on FIFO files, etc. *) do not log misleading errno in "not a regular file" error
-rw-r--r--src/core/ngx_open_file_cache.c9
-rw-r--r--src/http/modules/ngx_http_gzip_static_module.c2
-rw-r--r--src/http/modules/ngx_http_static_module.c2
-rw-r--r--src/os/unix/ngx_files.h1
-rw-r--r--src/os/win32/ngx_files.h1
5 files changed, 12 insertions, 3 deletions
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
index 5f6e0b263..034bf3b60 100644
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -487,7 +487,14 @@ ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log)
}
if (!of->log) {
- fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
+
+ /*
+ * Use non-blocking open() not to hang on FIFO files, etc.
+ * This flag has no effect on a regular files.
+ */
+
+ fd = ngx_open_file(name, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
+ NGX_FILE_OPEN, 0);
} else {
fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN,
diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c
index 29874a33a..6ba3cd82b 100644
--- a/src/http/modules/ngx_http_gzip_static_module.c
+++ b/src/http/modules/ngx_http_gzip_static_module.c
@@ -179,7 +179,7 @@ ngx_http_gzip_static_handler(ngx_http_request_t *r)
#if !(NGX_WIN32) /* the not regular files are probably Unix specific */
if (!of.is_file) {
- ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
+ ngx_log_error(NGX_LOG_CRIT, log, 0,
"\"%s\" is not a regular file", path.data);
return NGX_HTTP_NOT_FOUND;
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index bc46b84a7..258ed21ec 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -188,7 +188,7 @@ ngx_http_static_handler(ngx_http_request_t *r)
#if !(NGX_WIN32) /* the not regular files are probably Unix specific */
if (!of.is_file) {
- ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
+ ngx_log_error(NGX_LOG_CRIT, log, 0,
"\"%s\" is not a regular file", path.data);
return NGX_HTTP_NOT_FOUND;
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index c9144f31b..361c1bbd3 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -64,6 +64,7 @@ typedef struct {
#define NGX_FILE_OPEN 0
#define NGX_FILE_TRUNCATE O_CREAT|O_TRUNC
#define NGX_FILE_APPEND O_WRONLY|O_APPEND
+#define NGX_FILE_NONBLOCK O_NONBLOCK
#define NGX_FILE_DEFAULT_ACCESS 0644
#define NGX_FILE_OWNER_ACCESS 0600
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index c11379f4f..7d01736c2 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -64,6 +64,7 @@ ngx_fd_t ngx_open_file(u_char *name, u_long mode, u_long create, u_long access);
#define NGX_FILE_WRONLY GENERIC_WRITE
#define NGX_FILE_RDWR GENERIC_READ|GENERIC_WRITE
#define NGX_FILE_APPEND FILE_APPEND_DATA|SYNCHRONIZE
+#define NGX_FILE_NONBLOCK 0
#define NGX_FILE_CREATE_OR_OPEN OPEN_ALWAYS
#define NGX_FILE_OPEN OPEN_EXISTING