]> git.kaiwu.me - nginx.git/commitdiff
use non-blocking open() not to hang on FIFO files, etc.
authorIgor Sysoev <igor@sysoev.ru>
Wed, 21 Apr 2010 15:59:36 +0000 (15:59 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 21 Apr 2010 15:59:36 +0000 (15:59 +0000)
src/core/ngx_open_file_cache.c
src/os/unix/ngx_files.h
src/os/win32/ngx_files.h

index 6aa66fd4ee32c0240246f02958cd8eb792cb3566..a9c45324d51123bf57357b32aec4762441942fa5 100644 (file)
@@ -490,7 +490,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 ccaf44a93dee7134deb3744fba62b1a09fa76036..f41eba5817a516bf93c74a84b00772e5bf6ee5d2 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 610fcd0dcf94f56bf21cd88e18b22260de507b42..c5bb888070631a042518584988663c74fe287eae 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