Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-07-30 16:34:04 +0400
committerIgor Sysoev <igor@sysoev.ru>2008-07-30 16:34:04 +0400
commit385af286421e983f744f7f5d339b8060ccd36302 (patch)
tree81c46d0dad40506cc3a331c6ffaf454da85a0177 /src/os
parent749449097847cc3bee9e4e3966122a94149b755b (diff)
directio
Diffstat (limited to 'src/os')
-rw-r--r--src/os/unix/ngx_alloc.h4
-rw-r--r--src/os/unix/ngx_files.c19
-rw-r--r--src/os/unix/ngx_files.h18
-rw-r--r--src/os/win32/ngx_files.h6
4 files changed, 44 insertions, 3 deletions
diff --git a/src/os/unix/ngx_alloc.h b/src/os/unix/ngx_alloc.h
index 8b7b766b2..c7a31aa54 100644
--- a/src/os/unix/ngx_alloc.h
+++ b/src/os/unix/ngx_alloc.h
@@ -21,8 +21,8 @@ void *ngx_calloc(size_t size, ngx_log_t *log);
/*
* Linux has memalign() or posix_memalign()
* Solaris has memalign()
- * FreeBSD has not memalign() or posix_memalign() but its malloc() alignes
- * allocations bigger than page size at the page boundary.
+ * FreeBSD 7.0 has posix_memalign(), besides, early version's malloc()
+ * aligns allocations bigger than page size at the page boundary
*/
#if (NGX_HAVE_POSIX_MEMALIGN || NGX_HAVE_MEMALIGN)
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 7ee8cbd84..e2148d843 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -351,3 +351,22 @@ ngx_unlock_fd(ngx_fd_t fd)
return 0;
}
+
+
+#if (NGX_HAVE_O_DIRECT)
+
+ngx_int_t
+ngx_directio(ngx_fd_t fd)
+{
+ int flags;
+
+ flags = fcntl(fd, F_GETFL);
+
+ if (flags == -1) {
+ return -1;
+ }
+
+ return fcntl(fd, F_SETFL, flags | O_DIRECT);
+}
+
+#endif
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 0c080c494..62af63bce 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -189,4 +189,22 @@ ngx_err_t ngx_unlock_fd(ngx_fd_t fd);
#define ngx_unlock_fd_n "fcntl(F_SETLK, F_UNLCK)"
+#if (NGX_HAVE_O_DIRECT)
+
+ngx_int_t ngx_directio(ngx_fd_t fd);
+#define ngx_directio_n "fcntl(O_DIRECT)"
+
+#elif (NGX_HAVE_F_NOCACHE)
+
+#define ngx_directio(fd) fcntl(fd, F_NOCACHE, 1)
+#define ngx_directio_n "fcntl(F_NOCACHE)"
+
+#else
+
+#define ngx_directio(fd) 0
+#define ngx_directio_n "ngx_directio_n"
+
+#endif
+
+
#endif /* _NGX_FILES_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 0c4e14fa3..5973e95b3 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -200,7 +200,7 @@ typedef struct {
ngx_int_t ngx_open_glob(ngx_glob_t *gl);
-#define ngx_open_glob_n "FindFirstFile()"
+#define ngx_open_glob_n "FindFirstFile()"
ngx_int_t ngx_read_glob(ngx_glob_t *gl, ngx_str_t *name);
void ngx_close_glob(ngx_glob_t *gl);
@@ -216,4 +216,8 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *ce,
off_t offset, ngx_pool_t *pool);
+#define ngx_directio(fd) 0
+#define ngx_directio_n "ngx_directio_n"
+
+
#endif /* _NGX_FILES_H_INCLUDED_ */