[nginx] svn commit: r4452 - in branches/stable-1.0: . src/http src/os/unix

mdounin at mdounin.ru mdounin at mdounin.ru
Sun Feb 5 20:05:12 UTC 2012


Author: mdounin
Date: 2012-02-05 20:05:11 +0000 (Sun, 05 Feb 2012)
New Revision: 4452

Log:
Merge of r4416:

Fixed AIO error handling on FreeBSD.

The aio_return() must be called regardless of the error returned by   
aio_error().  Not calling it resulted in various problems up to segmentation
faults (as AIO events are level-triggered and were reported again and again).

Additionally, in "aio sendfile" case r->blocked was incremented in case of
error returned from ngx_file_aio_read(), thus causing request hangs.


Modified:
   branches/stable-1.0/
   branches/stable-1.0/src/http/ngx_http_copy_filter_module.c
   branches/stable-1.0/src/os/unix/ngx_file_aio_read.c


Property changes on: branches/stable-1.0
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4309,4313,4315,4320-4321,4326-4327,4335-4336,4338-4343,4372-4375,4377,4379,4381-4385,4393,4396,4398,4400-4406,4413,4415
   + /trunk:3960-3974,3977-3987,3991-3996,3998,4000-4018,4020,4023,4025-4027,4034-4065,4073,4077,4086-4090,4094-4102,4106-4108,4113-4114,4129-4137,4143-4144,4147-4158,4177,4179,4182-4184,4186-4187,4189-4205,4207,4209-4210,4212,4217-4223,4227-4232,4235-4237,4265-4268,4270,4274-4276,4278-4280,4282-4284,4294-4295,4298,4300-4309,4313,4315,4320-4321,4326-4327,4335-4336,4338-4343,4372-4375,4377,4379,4381-4385,4393,4396,4398,4400-4406,4413,4415-4416

Modified: branches/stable-1.0/src/http/ngx_http_copy_filter_module.c
===================================================================
--- branches/stable-1.0/src/http/ngx_http_copy_filter_module.c	2012-02-05 20:02:59 UTC (rev 4451)
+++ branches/stable-1.0/src/http/ngx_http_copy_filter_module.c	2012-02-05 20:05:11 UTC (rev 4452)
@@ -190,7 +190,7 @@
 
             rc = n;
 
-            if (file->aio) {
+            if (rc == NGX_AGAIN) {
                 file->aio->data = r;
                 file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
 

Modified: branches/stable-1.0/src/os/unix/ngx_file_aio_read.c
===================================================================
--- branches/stable-1.0/src/os/unix/ngx_file_aio_read.c	2012-02-05 20:02:59 UTC (rev 4451)
+++ branches/stable-1.0/src/os/unix/ngx_file_aio_read.c	2012-02-05 20:05:11 UTC (rev 4452)
@@ -157,24 +157,15 @@
         return NGX_ERROR;
     }
 
-    if (n != 0) {
-        if (n == NGX_EINPROGRESS) {
-            if (ev->ready) {
-                ev->ready = 0;
-                ngx_log_error(NGX_LOG_ALERT, file->log, n,
-                              "aio_read(\"%V\") still in progress",
-                              &file->name);
-            }
-
-            return NGX_AGAIN;
+    if (n == NGX_EINPROGRESS) {
+        if (ev->ready) {
+            ev->ready = 0;
+            ngx_log_error(NGX_LOG_ALERT, file->log, n,
+                          "aio_read(\"%V\") still in progress",
+                          &file->name);
         }
 
-        aio->err = n;
-        ev->ready = 0;
-
-        ngx_log_error(NGX_LOG_CRIT, file->log, n,
-                      "aio_read(\"%V\") failed", &file->name);
-        return NGX_ERROR;
+        return NGX_AGAIN;
     }
 
     n = aio_return(&aio->aiocb);
@@ -182,9 +173,9 @@
     if (n == -1) {
         err = ngx_errno;
         aio->err = err;
-        ev->ready = 0;
+        ev->ready = 1;
 
-        ngx_log_error(NGX_LOG_ALERT, file->log, err,
+        ngx_log_error(NGX_LOG_CRIT, file->log, err,
                       "aio_return(\"%V\") failed", &file->name);
         return NGX_ERROR;
     }



More information about the nginx-devel mailing list