diff src/http/ngx_http_request.c @ 74:77969b24f355 NGINX_0_1_37

nginx 0.1.37 *) Change: now the "\n" is added to the end of the "nginx.pid" file. *) Bugfix: the responses may be transferred not completely, if many parts or the big parts were included by SSI. *) Bugfix: if all backends had returned the 404 reponse and the "http_404" parameter of the "proxy_next_upstream" or "fastcgi_next_upstream" directives was used, then nginx started to request all backends again.
author Igor Sysoev <http://sysoev.ru>
date Thu, 23 Jun 2005 00:00:00 +0400
parents b31656313b59
children da9a3b14312d
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -31,7 +31,7 @@ static ngx_int_t ngx_http_process_reques
 static ngx_int_t ngx_http_find_virtual_server(ngx_http_request_t *r);
 
 static void ngx_http_request_handler(ngx_event_t *ev);
-static void ngx_http_set_write_handler(ngx_http_request_t *r);
+static ngx_int_t ngx_http_set_write_handler(ngx_http_request_t *r);
 static void ngx_http_writer(ngx_http_request_t *r);
 static ngx_int_t ngx_http_postponed_handler(ngx_http_request_t *r);
 
@@ -1433,7 +1433,9 @@ ngx_http_finalize_request(ngx_http_reque
     }
 
     if (r->parent || rc == NGX_AGAIN) {
-        r->write_event_handler = ngx_http_writer;
+        if (ngx_http_set_write_handler(r) != NGX_OK) {
+            return;
+        }
     }
 
     r->done = 1;
@@ -1497,7 +1499,7 @@ ngx_http_finalize_request(ngx_http_reque
         return;
 
     } else if (rc == NGX_AGAIN || r->out) {
-        ngx_http_set_write_handler(r);
+        (void) ngx_http_set_write_handler(r);
         return;
     }
 
@@ -1541,7 +1543,7 @@ ngx_http_finalize_request(ngx_http_reque
 }
 
 
-static void
+static ngx_int_t
 ngx_http_set_write_handler(ngx_http_request_t *r)
 {
     ngx_event_t               *wev;
@@ -1549,10 +1551,12 @@ ngx_http_set_write_handler(ngx_http_requ
 
     r->http_state = NGX_HTTP_WRITING_REQUEST_STATE;
 
+    r->write_event_handler = ngx_http_writer;
+
     wev = r->connection->write;
 
     if (wev->ready && wev->delayed) {
-        return;
+        return NGX_OK;
     }
 
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
@@ -1563,7 +1567,10 @@ ngx_http_set_write_handler(ngx_http_requ
     if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) {
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
+        return NGX_ERROR;
     }
+
+    return NGX_OK;
 }