comparison src/core/ngx_open_file_cache.c @ 665:0b460e61bdcd default tip

Merge with nginx 1.0.0.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 25 Apr 2011 04:22:17 +0400
parents 566e105a89f1
children
comparison
equal deleted inserted replaced
572:06419a2298a9 665:0b460e61bdcd
13 * open file cache caches 13 * open file cache caches
14 * open file handles with stat() info; 14 * open file handles with stat() info;
15 * directories stat() info; 15 * directories stat() info;
16 * files and directories errors: not found, access denied, etc. 16 * files and directories errors: not found, access denied, etc.
17 */ 17 */
18
19
20 #define NGX_MIN_READ_AHEAD (128 * 1024)
18 21
19 22
20 static void ngx_open_file_cache_cleanup(void *data); 23 static void ngx_open_file_cache_cleanup(void *data);
21 static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, 24 static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of,
22 ngx_log_t *log); 25 ngx_log_t *log);
485 goto done; 488 goto done;
486 } 489 }
487 } 490 }
488 491
489 if (!of->log) { 492 if (!of->log) {
490 fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); 493
494 /*
495 * Use non-blocking open() not to hang on FIFO files, etc.
496 * This flag has no effect on a regular files.
497 */
498
499 fd = ngx_open_file(name, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
500 NGX_FILE_OPEN, 0);
491 501
492 } else { 502 } else {
493 fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN, 503 fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN,
494 NGX_FILE_DEFAULT_ACCESS); 504 NGX_FILE_DEFAULT_ACCESS);
495 } 505 }
522 of->fd = NGX_INVALID_FILE; 532 of->fd = NGX_INVALID_FILE;
523 533
524 } else { 534 } else {
525 of->fd = fd; 535 of->fd = fd;
526 536
537 if (of->read_ahead && ngx_file_size(&fi) > NGX_MIN_READ_AHEAD) {
538 if (ngx_read_ahead(fd, of->read_ahead) == NGX_ERROR) {
539 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
540 ngx_read_ahead_n " \"%s\" failed", name);
541 }
542 }
543
527 if (of->directio <= ngx_file_size(&fi)) { 544 if (of->directio <= ngx_file_size(&fi)) {
528 if (ngx_directio_on(fd) == -1) { 545 if (ngx_directio_on(fd) == NGX_FILE_ERROR) {
529 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 546 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
530 ngx_directio_on_n " \"%s\" failed", name); 547 ngx_directio_on_n " \"%s\" failed", name);
531 548
532 } else { 549 } else {
533 of->is_directio = 1; 550 of->is_directio = 1;