diff src/http/ngx_http_request.c @ 142:cb77c084acdb

nginx-0.0.1-2003-10-09-11:00:45 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 09 Oct 2003 07:00:45 +0000
parents src/http/ngx_http_event.c@2a615b036870
children 5526213be452
line wrap: on
line diff
copy from src/http/ngx_http_event.c
copy to src/http/ngx_http_request.c
--- a/src/http/ngx_http_event.c
+++ b/src/http/ngx_http_request.c
@@ -785,6 +785,10 @@ void ngx_http_finalize_request(ngx_http_
     int           rc;
     ngx_event_t  *rev, *wev;
 
+    if (r->main) {
+        return;
+    }
+
     rc = error;
 
     if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
@@ -813,9 +817,25 @@ void ngx_http_finalize_request(ngx_http_
             return;
         }
 
+#if 1
+        return;
+#endif
+
     } else if (rc == NGX_ERROR) {
         r->keepalive = 0;
         r->lingering_close = 0;
+
+    } else {
+        if (ngx_http_send_last(r) == NGX_ERROR) {
+            ngx_http_close_request(r, 0);
+            ngx_http_close_connection(r->connection);
+            return;
+        }
+
+        if (rc == NGX_AGAIN) {
+            ngx_http_set_write_handler(r);
+            return;
+        }
     }
 
     rev = r->connection->read;
@@ -840,6 +860,8 @@ void ngx_http_finalize_request(ngx_http_
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
     }
+
+    return;
 }
 
 
@@ -887,6 +909,8 @@ void ngx_http_set_write_handler(ngx_http
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
     }
+
+    return;
 }
 
 
@@ -951,6 +975,8 @@ static void ngx_http_writer(ngx_event_t 
         ngx_http_close_request(r, 0);
         ngx_http_close_connection(r->connection);
     }
+
+    return;
 }
 
 
@@ -1046,6 +1072,8 @@ static void ngx_http_read_discarded_body
         ngx_http_close_request(r, rc);
         ngx_http_close_connection(c);
     }
+
+    return;
 }
 
 
@@ -1385,6 +1413,17 @@ static void ngx_http_empty_handler(ngx_e
 }
 
 
+int ngx_http_send_last(ngx_http_request_t *r)
+{
+    ngx_hunk_t  *h;
+
+    ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
+    h->type = NGX_HUNK_LAST;
+
+    return ngx_http_output_filter(r, h);
+}
+
+
 void ngx_http_close_request(ngx_http_request_t *r, int error)
 {
     ngx_http_log_ctx_t  *ctx;