Forum: NGINX fix ngx_reset_pool

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F2dbd3dabc1953536cfca0043ec6cf48?d=identicon&s=25 梁思健 (Guest)
on 2016-07-18 18:39
(Received via mailing list)
# HG changeset patch
# User Liang Sijian <liangsijian@foxmail.com>
# Date 1468859189 -28800
#      Tue Jul 19 00:26:29 2016 +0800
# Node ID 45ef1e0a48a82b2a81db6bc447aaeb16a10056f9
# Parent  6acaa638fa074dada02ad4544a299584da9abc85
fix ngx_reset_pool

diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -109,7 +109,8 @@ ngx_reset_pool(ngx_pool_t *pool)
     }

     for (p = pool; p; p = p->d.next) {
-        p->d.last = (u_char *) p + sizeof(ngx_pool_t);
+        p->d.last = (u_char *) p +
+            (p == pool ? sizeof(ngx_pool_t ) :
sizeof(ngx_pool_data_t));
         p->d.failed = 0;
     }
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2016-07-18 20:50
(Received via mailing list)
Hello!

On Tue, Jul 19, 2016 at 12:38:58AM +0800, 梁思健 wrote:

> +++ b/src/core/ngx_palloc.c
> @@ -109,7 +109,8 @@ ngx_reset_pool(ngx_pool_t *pool)
>      }
>
>      for (p = pool; p; p = p->d.next) {
> -        p->d.last = (u_char *) p + sizeof(ngx_pool_t);
> +        p->d.last = (u_char *) p +
> +            (p == pool ? sizeof(ngx_pool_t ) : sizeof(ngx_pool_data_t));
>          p->d.failed = 0;
>      }

A previous attempt to "fix" this can be found here, it looks
slightly better from my point of view:

http://mailman.nginx.org/pipermail/nginx-devel/201...

Though we are quite happy with the current code, while it is not
optimal - it is simple and good enough from practical point of
view.

--
Maxim Dounin
http://nginx.org/
This topic is locked and can not be replied to.