]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.1-2003-10-08-08:34:07 import
authorIgor Sysoev <igor@sysoev.ru>
Wed, 8 Oct 2003 04:34:07 +0000 (04:34 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Wed, 8 Oct 2003 04:34:07 +0000 (04:34 +0000)
src/event/ngx_event_connect.c
src/event/ngx_event_proxy.c
src/http/modules/proxy/ngx_http_proxy_handler.c

index 7018379de818c558477182e4b6dfac84af3238d8..72031d95a89442c40f9159db088ed542262edff6 100644 (file)
@@ -161,6 +161,7 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
     rev->data = wev->data = c;
     c->read = rev;
     c->write = wev;
+    wev->write = 1;
 
     rev->instance = wev->instance = !instance;
 
index ce22c65015e778e110d847262ac63c33569af29c..2255626a0596999d643f01988c2c4189d71ba342 100644 (file)
@@ -9,7 +9,7 @@
 
 #if (NGX_EVENT_COPY_FILTER)
 static int ngx_event_proxy_copy_input_filter(ngx_event_proxy_t *p,
-                                                           ngx_chain_t *chain);
+                                             ngx_chain_t *chain);
 #endif
 
 
@@ -109,7 +109,7 @@ ngx_log_debug(p->log, "new hunk: %08X" _ chain->hunk);
 ngx_log_debug(p->log, "file hunk: %08X" _ chain->hunk _
               chain->hunk->end - chain->hunk->last);
 
-            /* if the hunks is not needed to be saved in a cache and
+            /* if the hunks are not needed to be saved in a cache and
                a downstream is ready then write the hunks to a downstream */
 
             } else if (p->cachable == 0 && p->downstream->write->ready) {
@@ -709,7 +709,7 @@ ngx_log_debug(p->log, "event proxy file hunk: %08X:%08X" _ h _ h->shadow);
 /* the copy input filter */
 
 static int ngx_event_proxy_copy_input_filter(ngx_event_proxy_t *p,
-                                                            ngx_chain_t *chain)
+                                             ngx_chain_t *chain)
 {
     ngx_hunk_t   *h;
     ngx_chain_t  *entry, *temp;
index 2888e4cfa8374b1a623e68851eb1cadc8a61ef4f..9333c954c06f04c6ca767c4f912ca31ecee8076c 100644 (file)
@@ -779,12 +779,25 @@ static void ngx_http_proxy_process_upstream_body(ngx_event_t *rev)
     ngx_log_debug(rev->log, "http proxy process upstream body");
 
     if (rev->timedout) {
-        ngx_http_proxy_next_upstream(p);
+        ngx_http_proxy_close_connection(p->upstream.connection);
+        p->upstream.connection = NULL;
         return;
     }
 
     ngx_event_proxy_read_upstream(p->event_proxy);
 
+    if (p->event_proxy->upstream_eof) {
+        ngx_http_proxy_close_connection(p->upstream.connection);
+        p->upstream.connection = NULL;
+        return;
+    }
+
+    if (p->event_proxy->upstream_error) {
+        ngx_http_proxy_close_connection(p->upstream.connection);
+        p->upstream.connection = NULL;
+        return;
+    }
+
     return;
 }
 
@@ -1043,6 +1056,8 @@ static void ngx_http_proxy_close_connection(ngx_connection_t *c)
         c->write->timer_set = 0;
     }
 
+    /* TODO: move connection to the connection pool */
+
     if (ngx_del_conn) {
         ngx_del_conn(c);