summaryrefslogtreecommitdiffhomepage
path: root/src/os/unix/ngx_linux_aio_read.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2011-09-30 14:12:53 +0000
committerIgor Sysoev <igor@sysoev.ru>2011-09-30 14:12:53 +0000
commit287e2cae6dcce09bcfa464e87edd65c602811d16 (patch)
treeb97f441e239dda59e3f81de0a0f83e1912ff9b52 /src/os/unix/ngx_linux_aio_read.c
parent6f23d1a5817fd7e15d643d5ed8ddbbe37cfd6664 (diff)
downloadnginx-287e2cae6dcce09bcfa464e87edd65c602811d16.tar.gz
nginx-287e2cae6dcce09bcfa464e87edd65c602811d16.tar.bz2
Merging r4130, r4131, r4135:
Linux AIO related fixes: *) Fixing Linux AIO syscalls return value handling: syscall(2) uses usual libc convention, it returns -1 on error and sets errno. Obsolete _syscall(2) returns negative value of error. *) Fixing Linux AIO initiatialization: AIO operations are disabled if kernel does not support them. Previously worker just exited. *) The "worker_aio_requests" directive. The default value is 32 AIO simultaneous requests per worker. Previously they were hardcoded to 1024, and it was too large, since Linux allocated them early on io_setup(), but not on request itself. So with default value of /proc/sys/fs/aio-max-nr equal to 65536 only 64 worker processes could be run simultaneously. 32 AIO requests are enough for modern disks even if server runs only 1 worker.
Diffstat (limited to 'src/os/unix/ngx_linux_aio_read.c')
-rw-r--r--src/os/unix/ngx_linux_aio_read.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/os/unix/ngx_linux_aio_read.c b/src/os/unix/ngx_linux_aio_read.c
index b9d1d01cd..d31c4a064 100644
--- a/src/os/unix/ngx_linux_aio_read.c
+++ b/src/os/unix/ngx_linux_aio_read.c
@@ -16,7 +16,7 @@ extern aio_context_t ngx_aio_ctx;
static void ngx_file_aio_event_handler(ngx_event_t *ev);
-static long
+static int
io_submit(aio_context_t ctx, long n, struct iocb **paiocb)
{
return syscall(SYS_io_submit, ctx, n, paiocb);
@@ -27,7 +27,7 @@ ssize_t
ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset,
ngx_pool_t *pool)
{
- long n;
+ ngx_err_t err;
struct iocb *piocb[1];
ngx_event_t *ev;
ngx_event_aio_t *aio;
@@ -96,9 +96,7 @@ ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset,
piocb[0] = &aio->aiocb;
- n = io_submit(ngx_aio_ctx, 1, piocb);
-
- if (n == 1) {
+ if (io_submit(ngx_aio_ctx, 1, piocb) == 1) {
ev->active = 1;
ev->ready = 0;
ev->complete = 0;
@@ -106,16 +104,16 @@ ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset,
return NGX_AGAIN;
}
- n = -n;
+ err = ngx_errno;
- if (n == NGX_EAGAIN) {
+ if (err == NGX_EAGAIN) {
return ngx_read_file(file, buf, size, offset);
}
- ngx_log_error(NGX_LOG_CRIT, file->log, n,
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
"io_submit(\"%V\") failed", &file->name);
- if (n == NGX_ENOSYS) {
+ if (err == NGX_ENOSYS) {
ngx_file_aio = 0;
return ngx_read_file(file, buf, size, offset);
}