From 3266171fd4691d173f698f1c0c246322a94588e2 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Wed, 30 Sep 2009 13:21:52 +0000 Subject: read_ahead --- src/os/unix/ngx_files.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/os/unix/ngx_files.h') diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h index 993ce8f93..832dbbe0f 100644 --- a/src/os/unix/ngx_files.h +++ b/src/os/unix/ngx_files.h @@ -254,6 +254,28 @@ ngx_err_t ngx_unlock_fd(ngx_fd_t fd); #define ngx_unlock_fd_n "fcntl(F_SETLK, F_UNLCK)" +#if (NGX_HAVE_F_READAHEAD) + +#define NGX_HAVE_READ_AHEAD 1 + +#define ngx_read_ahead(fd, n) fcntl(fd, F_READAHEAD, (int) n) +#define ngx_read_ahead_n "fcntl(fd, F_READAHEAD)" + +#elif (NGX_HAVE_POSIX_FADVISE) + +#define NGX_HAVE_READ_AHEAD 1 + +#define ngx_read_ahead(fd, n) posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL) +#define ngx_read_ahead_n "posix_fadvise(POSIX_FADV_SEQUENTIAL)" + +#else + +#define ngx_read_ahead(fd, n) 0 +#define ngx_read_ahead_n "ngx_read_ahead_n" + +#endif + + #if (NGX_HAVE_O_DIRECT) ngx_int_t ngx_directio_on(ngx_fd_t fd); -- cgit v1.2.3