diff src/http/ngx_http_request.c @ 330:5e3b425174f6 NGINX_0_6_9

nginx 0.6.9 *) Bugfix: a worker process may got caught in an endless loop, if the HTTPS protocol was used; bug appeared in 0.6.7. *) Bugfix: if server listened on two addresses or ports and trailing wildcard was used, then nginx did not run. *) Bugfix: the "ip_hash" directive might incorrectly mark servers as down. *) Bugfix: nginx could not be built on amd64; bug appeared in 0.6.8.
author Igor Sysoev <http://sysoev.ru>
date Tue, 28 Aug 2007 00:00:00 +0400
parents 9fc4ab6673f9
children 3a91bfeffaba
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -836,7 +836,7 @@ ngx_http_process_request_headers(ngx_eve
                     ngx_log_error(NGX_LOG_INFO, c->log, 0,
                                   "client sent too long header line: \"%V\"",
                                   &header);
-                    ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST);
+                    ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
                     return;
                 }
             }
@@ -948,7 +948,7 @@ ngx_http_process_request_headers(ngx_eve
         ngx_log_error(NGX_LOG_INFO, c->log, 0,
                       "client sent invalid header line: \"%V\\r...\"",
                       &header);
-        ngx_http_close_request(r, NGX_HTTP_BAD_REQUEST);
+        ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
         return;
     }
 }
@@ -1556,6 +1556,7 @@ ngx_http_request_handler(ngx_event_t *ev
 void
 ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
 {
+    ngx_connection_t          *c;
     ngx_http_request_t        *pr;
     ngx_http_log_ctx_t        *ctx;
     ngx_http_core_loc_conf_t  *clcf;
@@ -1565,7 +1566,9 @@ ngx_http_finalize_request(ngx_http_reque
         return;
     }
 
-    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+    c = r->connection;
+
+    ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http finalize request: %d, \"%V?%V\"",
                    rc, &r->uri, &r->args);
 
@@ -1580,10 +1583,7 @@ ngx_http_finalize_request(ngx_http_reque
         rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc);
     }
 
-    if (rc == NGX_ERROR
-        || rc == NGX_HTTP_REQUEST_TIME_OUT
-        || r->connection->error)
-    {
+    if (rc == NGX_ERROR || rc == NGX_HTTP_REQUEST_TIME_OUT || c->error) {
         if (rc > 0 && r->headers_out.status == 0) {
             r->headers_out.status = rc;
         }
@@ -1606,12 +1606,12 @@ ngx_http_finalize_request(ngx_http_reque
         }
 
         if (r == r->main) {
-            if (r->connection->read->timer_set) {
-                ngx_del_timer(r->connection->read);
+            if (c->read->timer_set) {
+                ngx_del_timer(c->read);
             }
 
-            if (r->connection->write->timer_set) {
-                ngx_del_timer(r->connection->write);
+            if (c->write->timer_set) {
+                ngx_del_timer(c->write);
             }
         }
 
@@ -1627,8 +1627,8 @@ ngx_http_finalize_request(ngx_http_reque
 
     r->done = 1;
 
-    if (r != r->connection->data) {
-        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+    if (r != c->data) {
+        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                        "http finalize non-active request: \"%V?%V\"",
                        &r->uri, &r->args);
         return;
@@ -1638,19 +1638,19 @@ ngx_http_finalize_request(ngx_http_reque
 
         pr = r->parent;
 
-        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+        ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                        "http parent request: \"%V?%V\"", &pr->uri, &pr->args);
 
         if (rc != NGX_AGAIN) {
-            r->connection->data = pr;
+            c->data = pr;
         }
 
-        ctx = r->connection->log->data;
+        ctx = c->log->data;
         ctx->current_request = pr;
 
         if (pr->postponed) {
 
-            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+            ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                            "http request: \"%V?%V\" has postponed",
                            &pr->uri, &pr->args);
 
@@ -1664,14 +1664,14 @@ ngx_http_finalize_request(ngx_http_reque
                     r->fast_subrequest = 0;
                 }
 
-                ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                            "http fast subrequest: \"%V?%V\" done",
                            &r->uri, &r->args);
                 return;
             }
 
             if (rc != NGX_AGAIN) {
-                ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
                                "http wake parent request: \"%V?%V\"",
                                &pr->uri, &pr->args);
 
@@ -1686,7 +1686,7 @@ ngx_http_finalize_request(ngx_http_reque
         return;
     }
 
-    if (r->connection->buffered) {
+    if (c->buffered) {
         (void) ngx_http_set_write_handler(r);
         return;
     }
@@ -1699,16 +1699,21 @@ ngx_http_finalize_request(ngx_http_reque
         return;
     }
 
-    if (r->connection->read->timer_set) {
-        ngx_del_timer(r->connection->read);
+    if (c->read->timer_set) {
+        ngx_del_timer(c->read);
+    }
+
+    if (c->write->timer_set) {
+        c->write->delayed = 0;
+        ngx_del_timer(c->write);
     }
 
-    if (r->connection->write->timer_set) {
-        r->connection->write->delayed = 0;
-        ngx_del_timer(r->connection->write);
+    if (c->destroyed) {
+        return;
     }
 
-    if (r->connection->destroyed) {
+    if (c->read->eof) {
+        ngx_http_close_request(r, 0);
         return;
     }