]> git.kaiwu.me - nginx.git/commitdiff
merge r3498, r3499:
authorIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jun 2010 12:08:44 +0000 (12:08 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 7 Jun 2010 12:08:44 +0000 (12:08 +0000)
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

src/core/ngx_open_file_cache.c
src/http/modules/ngx_http_gzip_static_module.c
src/http/modules/ngx_http_static_module.c
src/os/unix/ngx_files.h
src/os/win32/ngx_files.h

index 5f6e0b263e058f8122ce27afaf4d8349f89203ab..034bf3b6033a1e5728f4c2923be46661b6f0ebab 100644 (file)
@@ -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,
index 29874a33a2951e8d59fcbf6d4b988f370ec1a603..6ba3cd82b7db3c3b6d86cd72bca4997d5649de71 100644 (file)
@@ -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;
index bc46b84a775ebdb1f78a17d2a02edd40bccf1ee5..258ed21ec39b88309c7e0e23f037031a6b281ee2 100644 (file)
@@ -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;
index c9144f31b367409966952401f667fcf10bbf4ee6..361c1bbd333fa6f2db902969fed82a56b63ab3dc 100644 (file)
@@ -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
index c11379f4f9a427c0639c36671a0e421985b74d75..7d01736c293041dbbd35ad7f17a088dce1299442 100644 (file)
@@ -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