diff src/http/ngx_http_request.c @ 76:da9a3b14312d NGINX_0_1_38

nginx 0.1.38 *) Feature: the "limit_rate" directive is supported in in proxy and FastCGI mode. *) Feature: the "X-Accel-Limit-Rate" response header line is supported in proxy and FastCGI mode. *) Feature: the "break" directive. *) Feature: the "log_not_found" directive. *) Bugfix: the response status code was not changed when request was redirected by the ""X-Accel-Redirect" header line. *) Bugfix: the variables set by the "set" directive could not be used in SSI. *) Bugfix: the segmentation fault may occurred if the SSI page has more than one remote subrequest. *) Bugfix: nginx treated the backend response as invalid if the status line in the header was transferred in two packets; bug appeared in 0.1.29. *) Feature: the "ssi_types" directive. *) Feature: the "autoindex_exact_size" directive. *) Bugfix: the ngx_http_autoindex_module did not support the long file names in UTF-8. *) Feature: the IMAP/POP3 proxy.
author Igor Sysoev <http://sysoev.ru>
date Fri, 08 Jul 2005 00:00:00 +0400
parents 77969b24f355
children 6ae11d59d10e
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -90,11 +90,6 @@ ngx_http_header_t  ngx_http_headers_in[]
     { ngx_string("Range"), offsetof(ngx_http_headers_in_t, range),
                  ngx_http_process_header_line },
 
-#if 0
-    { ngx_string("If-Range"), offsetof(ngx_http_headers_in_t, if_range),
-                 ngx_http_process_header_line },
-#endif
-
 #if (NGX_HTTP_GZIP)
     { ngx_string("Accept-Encoding"),
                  offsetof(ngx_http_headers_in_t, accept_encoding),
@@ -1441,6 +1436,8 @@ ngx_http_finalize_request(ngx_http_reque
     r->done = 1;
 
     if (r != r->connection->data) {
+        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                       "http finalize non-active request: \"%V\"", &r->uri);
         return;
     }
 
@@ -1448,12 +1445,18 @@ ngx_http_finalize_request(ngx_http_reque
 
         pr = r->parent;
 
+        ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                       "http parent request: \"%V\"", &pr->uri);
+
         if (rc != NGX_AGAIN) {
             pr->connection->data = pr;
         }
 
         if (pr->postponed) {
 
+            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                           "http request: \"%V\" has postponed", &pr->uri);
+
             if (rc != NGX_AGAIN && pr->postponed->request == r) {
                 pr->postponed = pr->postponed->next;
 
@@ -1462,9 +1465,13 @@ ngx_http_finalize_request(ngx_http_reque
                 }
             }
 
+            ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                           "http request: \"%V\" still has postponed",
+                           &pr->uri);
+
             if (pr->done) {
                 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                               "http wake request: \"%V\"", &pr->uri);
+                               "http wake parent request: \"%V\"", &pr->uri);
 
                 pr->write_event_handler(pr);
             }
@@ -1483,7 +1490,7 @@ ngx_http_finalize_request(ngx_http_reque
             ngx_del_timer(r->connection->write);
         }
 
-        if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
+        if (r->connection->closed) {
             ngx_http_close_request(r, 0);
             ngx_http_close_connection(r->connection);
             return;
@@ -1492,13 +1499,15 @@ ngx_http_finalize_request(ngx_http_reque
         ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
 
         return;
-
-    } else if (rc == NGX_ERROR) {
+    }
+
+    if (rc == NGX_ERROR || r->connection->closed) {
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
         return;
-
-    } else if (rc == NGX_AGAIN || r->out) {
+    }
+
+    if (rc == NGX_AGAIN || r->out) {
         (void) ngx_http_set_write_handler(r);
         return;
     }
@@ -1553,6 +1562,10 @@ ngx_http_set_write_handler(ngx_http_requ
 
     r->write_event_handler = ngx_http_writer;
 
+    if (r->connection->closed) {
+        return NGX_OK;
+    }
+
     wev = r->connection->write;
 
     if (wev->ready && wev->delayed) {
@@ -1673,6 +1686,9 @@ static ngx_int_t
 ngx_http_postponed_handler(ngx_http_request_t *r)
 {
     ngx_int_t                      rc;
+#if 0
+    ngx_http_request_t            *mr;
+#endif
     ngx_http_postponed_request_t  *pr;
 
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
@@ -1687,20 +1703,16 @@ ngx_http_postponed_handler(ngx_http_requ
         rc = ngx_http_output_filter(r, NULL);
 
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                           "http postponed output filter: %d", rc);
+                       "http postponed output filter: %d", rc);
 
         if (rc == NGX_AGAIN) {
             return rc;
         }
 
-        if (rc == NGX_ERROR) {
-            /* NGX_ERROR may be returned by any filter */
-            r->connection->write->error = 1;
-
-            ngx_http_finalize_request(r, rc);
-
-            return NGX_DONE;
-        }
+        /*
+         * we treat NGX_ERROR as NGX_OK, because we need to complete
+         * all postponed requests
+         */
 
         pr = r->postponed;
 
@@ -1713,7 +1725,7 @@ ngx_http_postponed_handler(ngx_http_requ
     r->connection->data = r;
 
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                   "http postponed request \"%V\"", &r->uri);
+                   "http wake child request \"%V\"", &r->uri);
 
     r->write_event_handler(r);
 
@@ -1833,7 +1845,7 @@ ngx_http_read_discarded_body(ngx_http_re
 
     if (n == NGX_ERROR) {
 
-        r->closed = 1;
+        r->connection->closed = 1;
 
         /*
          * if a client request body is discarded then we already set