diff src/os/unix/ngx_linux_aio_read.c @ 634:0d6525917227 NGINX_1_0_7

nginx 1.0.7 *) Change: now if total size of all ranges is greater than source response size, then nginx disables ranges and returns just the source response. *) Feature: the "max_ranges" directive. *) Feature: the module ngx_http_mp4_module. *) Feature: the "worker_aio_requests" directive. *) Bugfix: if nginx was built --with-file-aio it could not be run on Linux kernel which did not support AIO. *) Bugfix: in Linux AIO error processing. Thanks to Hagai Avrahami. *) Bugfix: in Linux AIO combined with open_file_cache. *) Bugfix: open_file_cache did not update file info on retest if file was not atomically changed. *) Bugfix: reduced memory consumption for long-lived requests. *) Bugfix: in the "proxy/fastcgi/scgi/uwsgi_ignore_client_abort" directives. *) Bugfix: nginx could not be built on MacOSX 10.7. *) Bugfix: in the "proxy/fastcgi/scgi/uwsgi_ignore_client_abort" directives. *) Bugfix: request body might be processed incorrectly if client used pipelining. *) Bugfix: in the "request_body_in_single_buf" directive. *) Bugfix: in "proxy_set_body" and "proxy_pass_request_body" directives if SSL connection to backend was used. *) Bugfix: nginx hogged CPU if all servers in an upstream were marked as "down". *) Bugfix: a segmentation fault might occur during reconfiguration if ssl_session_cache was defined but not used in previous configuration. *) Bugfix: a segmentation fault might occur in a worker process if many backup servers were used in an upstream.
author Igor Sysoev <http://sysoev.ru>
date Fri, 30 Sep 2011 00:00:00 +0400
parents c5122335e41d
children ad25218fd14b
line wrap: on
line diff
--- 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;
@@ -74,6 +74,10 @@ ngx_file_aio_read(ngx_file_t *file, u_ch
         }
 
         ngx_set_errno(-aio->res);
+
+        ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
+                      "aio read \"%s\" failed", file->name.data);
+
         return NGX_ERROR;
     }
 
@@ -92,9 +96,7 @@ ngx_file_aio_read(ngx_file_t *file, u_ch
 
     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;
@@ -102,16 +104,16 @@ ngx_file_aio_read(ngx_file_t *file, u_ch
         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);
     }