changeset 26:cb15f6f4d820

Keepalive: don't cache timed out connections.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 26 Jul 2011 12:51:14 +0400
parents c6396fef9295
children f3b50effc1d4
files ngx_http_upstream_keepalive_module.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ngx_http_upstream_keepalive_module.c
+++ b/ngx_http_upstream_keepalive_module.c
@@ -309,10 +309,13 @@ ngx_http_upstream_free_keepalive_peer(ng
      */
 
     u = kp->upstream;
+    c = pc->connection;
     status = u->headers_in.status_n;
 
     if (!kp->failed
-        && pc->connection != NULL
+        && c != NULL
+        && !c->read->timedout
+        && !c->write->timedout
 #if (NGX_UPSTREAM_KEEPALIVE_PATCHED)
         && u->keepalive)
 #else
@@ -320,8 +323,6 @@ ngx_http_upstream_free_keepalive_peer(ng
             || (status == NGX_HTTP_OK && u->header_sent && u->length == 0)))
 #endif
     {
-        c = pc->connection;
-
         ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0,
                        "free keepalive peer: saving connection %p", c);