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
Igor Sysoev
12 years ago
486 | 486 |
}
|
487 | 487 |
|
488 | 488 |
if (!of->log) {
|
489 | |
fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
|
|
489 |
|
|
490 |
/*
|
|
491 |
* Use non-blocking open() not to hang on FIFO files, etc.
|
|
492 |
* This flag has no effect on a regular files.
|
|
493 |
*/
|
|
494 |
|
|
495 |
fd = ngx_open_file(name, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
|
|
496 |
NGX_FILE_OPEN, 0);
|
490 | 497 |
|
491 | 498 |
} else {
|
492 | 499 |
fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN,
|
178 | 178 |
#if !(NGX_WIN32) /* the not regular files are probably Unix specific */
|
179 | 179 |
|
180 | 180 |
if (!of.is_file) {
|
181 | |
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
|
181 |
ngx_log_error(NGX_LOG_CRIT, log, 0,
|
182 | 182 |
"\"%s\" is not a regular file", path.data);
|
183 | 183 |
|
184 | 184 |
return NGX_HTTP_NOT_FOUND;
|
187 | 187 |
#if !(NGX_WIN32) /* the not regular files are probably Unix specific */
|
188 | 188 |
|
189 | 189 |
if (!of.is_file) {
|
190 | |
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
|
190 |
ngx_log_error(NGX_LOG_CRIT, log, 0,
|
191 | 191 |
"\"%s\" is not a regular file", path.data);
|
192 | 192 |
|
193 | 193 |
return NGX_HTTP_NOT_FOUND;
|
63 | 63 |
#define NGX_FILE_OPEN 0
|
64 | 64 |
#define NGX_FILE_TRUNCATE O_CREAT|O_TRUNC
|
65 | 65 |
#define NGX_FILE_APPEND O_WRONLY|O_APPEND
|
|
66 |
#define NGX_FILE_NONBLOCK O_NONBLOCK
|
66 | 67 |
|
67 | 68 |
#define NGX_FILE_DEFAULT_ACCESS 0644
|
68 | 69 |
#define NGX_FILE_OWNER_ACCESS 0600
|
63 | 63 |
#define NGX_FILE_WRONLY GENERIC_WRITE
|
64 | 64 |
#define NGX_FILE_RDWR GENERIC_READ|GENERIC_WRITE
|
65 | 65 |
#define NGX_FILE_APPEND FILE_APPEND_DATA|SYNCHRONIZE
|
|
66 |
#define NGX_FILE_NONBLOCK 0
|
66 | 67 |
|
67 | 68 |
#define NGX_FILE_CREATE_OR_OPEN OPEN_ALWAYS
|
68 | 69 |
#define NGX_FILE_OPEN OPEN_EXISTING
|