changeset 522:1bc8c12d80ec NGINX_0_8_13

nginx 0.8.13 *) Bugfix: in the "aio sendfile" directive. the bug had appeared in 0.8.12. *) Bugfix: nginx could not be built without the --with-file-aio option on FreeBSD; the bug had appeared in 0.8.12.
author Igor Sysoev <http://sysoev.ru>
date Mon, 31 Aug 2009 00:00:00 +0400
parents 9917c53346ac
children 441fbf722b8c
files CHANGES CHANGES.ru src/core/nginx.h src/http/modules/perl/nginx.pm src/http/ngx_http_copy_filter_module.c
diffstat 5 files changed, 66 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES	Mon Aug 31 00:00:00 2009 +0400
+++ b/CHANGES	Mon Aug 31 00:00:00 2009 +0400
@@ -1,4 +1,13 @@
 
+Changes with nginx 0.8.13                                        31 Aug 2009
+
+    *) Bugfix: in the "aio sendfile" directive. the bug had appeared in 
+       0.8.12.
+
+    *) Bugfix: nginx could not be built without the --with-file-aio option 
+       on FreeBSD; the bug had appeared in 0.8.12.
+
+
 Changes with nginx 0.8.12                                        31 Aug 2009
 
     *) Feature: the "sendfile" parameter in the "aio" directive on FreeBSD.
--- a/CHANGES.ru	Mon Aug 31 00:00:00 2009 +0400
+++ b/CHANGES.ru	Mon Aug 31 00:00:00 2009 +0400
@@ -1,4 +1,12 @@
 
+Изменения в nginx 0.8.13                                          31.08.2009
+
+    *) Исправление: в директиве "aio sendfile"; ошибка появилась в 0.8.12.
+
+    *) Исправление: nginx не собирался без параметра --with-file-aio на 
+       FreeBSD; ошибка появилась в 0.8.12.
+
+
 Изменения в nginx 0.8.12                                          31.08.2009
 
     *) Добавление: параметр sendfile в директиве aio во FreeBSD.
--- a/src/core/nginx.h	Mon Aug 31 00:00:00 2009 +0400
+++ b/src/core/nginx.h	Mon Aug 31 00:00:00 2009 +0400
@@ -8,8 +8,8 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define nginx_version         8012
-#define NGINX_VERSION      "0.8.12"
+#define nginx_version         8013
+#define NGINX_VERSION      "0.8.13"
 #define NGINX_VER          "nginx/" NGINX_VERSION
 
 #define NGINX_VAR          "NGINX"
--- a/src/http/modules/perl/nginx.pm	Mon Aug 31 00:00:00 2009 +0400
+++ b/src/http/modules/perl/nginx.pm	Mon Aug 31 00:00:00 2009 +0400
@@ -47,7 +47,7 @@
     HTTP_INSUFFICIENT_STORAGE
 );
 
-our $VERSION = '0.8.12';
+our $VERSION = '0.8.13';
 
 require XSLoader;
 XSLoader::load('nginx', $VERSION);
--- a/src/http/ngx_http_copy_filter_module.c	Mon Aug 31 00:00:00 2009 +0400
+++ b/src/http/ngx_http_copy_filter_module.c	Mon Aug 31 00:00:00 2009 +0400
@@ -133,55 +133,64 @@
         r->request_output = 1;
     }
 
-    rc = ngx_output_chain(ctx, in);
+    for ( ;; ) {
+        rc = ngx_output_chain(ctx, in);
 
-    if (ctx->in == NULL) {
-        r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
+        if (ctx->in == NULL) {
+            r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
+
+        } else {
+            r->buffered |= NGX_HTTP_COPY_BUFFERED;
+        }
 
-    } else {
-        r->buffered |= NGX_HTTP_COPY_BUFFERED;
-    }
+        ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
+                       "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
+
+#if (NGX_HAVE_FILE_AIO && NGX_HAVE_AIO_SENDFILE)
 
-    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
-                   "http copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
+        if (c->busy_sendfile) {
+            ssize_t                n;
+            off_t                  offset;
+            ngx_file_t            *file;
+            ngx_http_ephemeral_t  *e;
 
-#if (NGX_HAVE_AIO_SENDFILE)
+            file = c->busy_sendfile->file;
+            offset = c->busy_sendfile->file_pos;
 
-    if (c->busy_sendfile) {
-        off_t                  offset;
-        ngx_file_t            *file;
-        ngx_http_ephemeral_t  *e;
+            if (file->aio) {
+                c->aio_sendfile = (offset != file->aio->last_offset);
+                file->aio->last_offset = offset;
 
-        file = c->busy_sendfile->file;
-        offset = c->busy_sendfile->file_pos;
+                if (c->aio_sendfile == 0) {
+                    ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+                                  "sendfile(%V) returned busy again",
+                                  &file->name);
+                }
+            }
+
+            c->busy_sendfile = NULL;
+            e = (ngx_http_ephemeral_t *) &r->uri_start;
 
-        if (file->aio) {
-            c->aio_sendfile = (offset != file->aio->last_offset);
-            file->aio->last_offset = offset;
+            n = ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
+
+            if (n > 0) {
+                continue;
+            }
 
-            if (c->aio_sendfile == 0) {
-                ngx_log_error(NGX_LOG_ALERT, c->log, 0,
-                              "sendfile(%V) returned busy again", &file->name);
+            rc = n;
+
+            if (file->aio) {
+                file->aio->data = r;
+                file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
+
+                r->main->blocked++;
+                r->aio = 1;
             }
         }
-
-        c->busy_sendfile = NULL;
-        e = (ngx_http_ephemeral_t *) &r->uri_start;
-
-        (void) ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
-
-        if (file->aio) {
-            file->aio->data = r;
-            file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
-
-            r->main->blocked++;
-            r->aio = 1;
-        }
-    }
-
 #endif
 
-    return rc;
+        return rc;
+    }
 }