From 1954cf149aa79ba2bb1ce0b7b20422ab2ca6c93a Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Tue, 13 Nov 2012 11:21:31 +0000 Subject: [PATCH] Merge of r4892: keepalive memory usage optimization. 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 479b106cf..ee00fd3af 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -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; }