]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4892: keepalive memory usage optimization.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 13 Nov 2012 11:21:31 +0000 (11:21 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 13 Nov 2012 11:21:31 +0000 (11:21 +0000)
The ngx_http_keepalive_handler() function is now trying to not
keep c->buffer's memory for idle connections.

This behaviour is consistent with the ngx_http_set_keepalive()
function and it should decrease memory usage in some cases (especially
if epoll/rtsig is used).

src/http/ngx_http_request.c

index 479b106cfc8d23b867ca8ab12bb5b589827de539..ee00fd3af077f1c367da30192c3f0788e2fc9aee 100644 (file)
@@ -2745,6 +2745,20 @@ ngx_http_keepalive_handler(ngx_event_t *rev)
             ngx_http_close_connection(c);
         }
 
+        /*
+         * Like ngx_http_set_keepalive() we are trying to not hold
+         * c->buffer's memory for a keepalive connection.
+         */
+
+        if (ngx_pfree(c->pool, b->start) == NGX_OK) {
+
+            /*
+             * the special note that c->buffer's memory was freed
+             */
+
+            b->pos = NULL;
+        }
+
         return;
     }