Mercurial > hg > nginx
changeset 3322:e19df6e65352
fix posix_fadvise() error handling
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 15 Nov 2009 09:16:58 +0000 |
parents | 93e8daca5dbb |
children | 9421e997c2c4 |
files | src/os/unix/ngx_files.c src/os/unix/ngx_files.h |
diffstat | 2 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os/unix/ngx_files.c Sun Nov 15 09:03:08 2009 +0000 +++ b/src/os/unix/ngx_files.c Sun Nov 15 09:16:58 2009 +0000 @@ -402,6 +402,26 @@ } +#if (NGX_HAVE_POSIX_FADVISE) + +ngx_int_t +ngx_read_ahead(ngx_fd_t fd, size_t n) +{ + int err; + + err = posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); + + if (err == 0) { + return 0; + } + + ngx_set_errno(err); + return NGX_FILE_ERROR; +} + +#endif + + #if (NGX_HAVE_O_DIRECT) ngx_int_t
--- a/src/os/unix/ngx_files.h Sun Nov 15 09:03:08 2009 +0000 +++ b/src/os/unix/ngx_files.h Sun Nov 15 09:16:58 2009 +0000 @@ -264,7 +264,7 @@ #define NGX_HAVE_READ_AHEAD 1 -#define ngx_read_ahead(fd, n) posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL) +ngx_int_t ngx_read_ahead(ngx_fd_t fd, size_t n); #define ngx_read_ahead_n "posix_fadvise(POSIX_FADV_SEQUENTIAL)" #else