You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2022/07/21 11:21:30 UTC

svn commit: r1902909 - /httpd/httpd/trunk/server/util.c

Author: ylavic
Date: Thu Jul 21 11:21:30 2022
New Revision: 1902909

URL: http://svn.apache.org/viewvc?rev=1902909&view=rev
Log:
core: Follow up to r1902728 and r1902906: simplify for APR-1.8+.

apr_threadattr_max_free_set() is now in APR-1.8.x.


Modified:
    httpd/httpd/trunk/server/util.c

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1902909&r1=1902908&r2=1902909&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Thu Jul 21 11:21:30 2022
@@ -3347,7 +3347,7 @@ AP_DECLARE(apr_status_t) ap_thread_main_
      */
     if ((rv = apr_threadattr_create(&attr, pool))
             || (rv = apr_threadattr_detach_set(attr, 1))
-#if APR_VERSION_AT_LEAST(2,0,0)
+#if APR_VERSION_AT_LEAST(1,8,0)
             || (rv = apr_threadattr_max_free_set(attr, ap_max_mem_free))
 #endif
             || (rv = ap_thread_current_create(thread, attr, pool))) {
@@ -3355,19 +3355,6 @@ AP_DECLARE(apr_status_t) ap_thread_main_
         return rv;
     }
 
-#if APR_VERSION_AT_LEAST(1,8,0) && !APR_VERSION_AT_LEAST(2,0,0)
-    /* Don't let the thread's pool allocator with no limits, though there
-     * is possibly no allocator with APR <= 1.7 and APR_POOL_DEBUG.
-     */
-    {
-        apr_pool_t *tp = apr_thread_pool_get(*thread);
-        apr_allocator_t *ta = apr_pool_allocator_get(tp);
-        if (ta) {
-            apr_allocator_max_free_set(ta, ap_max_mem_free);
-        }
-    }
-#endif
-
     apr_pool_cleanup_register(pool, *thread, main_thread_cleanup,
                               apr_pool_cleanup_null);
     return APR_SUCCESS;
@@ -3398,12 +3385,12 @@ AP_DECLARE(apr_status_t) ap_thread_curre
             abort_fn(rv);
         return rv;
     }
+    apr_allocator_max_free_set(ta, ap_max_mem_free);
     rv = apr_pool_create_unmanaged_ex(&p, abort_fn, ta);
     if (rv != APR_SUCCESS) {
         return rv;
     }
     /* Don't let the thread's pool allocator with no limits */
-    apr_allocator_max_free_set(ta, ap_max_mem_free);
     apr_allocator_owner_set(ta, p);
 
     osthd = apr_os_thread_current();



Re: svn commit: r1902909 - /httpd/httpd/trunk/server/util.c

Posted by Yann Ylavic <yl...@gmail.com>.
On Thu, Jul 28, 2022 at 4:02 PM Ruediger Pluem <rp...@apache.org> wrote:
>
> On 7/21/22 1:21 PM, ylavic@apache.org wrote:
>
> > --- httpd/httpd/trunk/server/util.c (original)
> > +++ httpd/httpd/trunk/server/util.c Thu Jul 21 11:21:30 2022
>
> > @@ -3355,19 +3355,6 @@ AP_DECLARE(apr_status_t) ap_thread_main_
> >          return rv;
> >      }
> >
> > -#if APR_VERSION_AT_LEAST(1,8,0) && !APR_VERSION_AT_LEAST(2,0,0)
> > -    /* Don't let the thread's pool allocator with no limits, though there
> > -     * is possibly no allocator with APR <= 1.7 and APR_POOL_DEBUG.
> > -     */
> > -    {
> > -        apr_pool_t *tp = apr_thread_pool_get(*thread);
> > -        apr_allocator_t *ta = apr_pool_allocator_get(tp);
> > -        if (ta) {
> > -            apr_allocator_max_free_set(ta, ap_max_mem_free);
> > -        }
> > -    }
> > -#endif
> > -
>
> Why don't we do the above for APR <= 1.7? The code is now NULL safe for APR_POOL_DEBUG.

For APR <= 1.7 the ap_thread_current_create() implementation in httpd
(called above) will do that already, while for >= 1.8 we use/point to
apr_thread_current_create() directly and that does not set max_free by
default (but then we call apr_threadattr_max_free_set() explicitly).

>
> >      apr_pool_cleanup_register(pool, *thread, main_thread_cleanup,
> >                                apr_pool_cleanup_null);
> >      return APR_SUCCESS;
> > @@ -3398,12 +3385,12 @@ AP_DECLARE(apr_status_t) ap_thread_curre
> >              abort_fn(rv);
> >          return rv;
> >      }
> > +    apr_allocator_max_free_set(ta, ap_max_mem_free);
> >      rv = apr_pool_create_unmanaged_ex(&p, abort_fn, ta);
> >      if (rv != APR_SUCCESS) {
> >          return rv;
> >      }
> >      /* Don't let the thread's pool allocator with no limits */
>
> The comment should move as well.

Thanks, done in r1903522.

>
> > -    apr_allocator_max_free_set(ta, ap_max_mem_free);
> >      apr_allocator_owner_set(ta, p);
> >
> >      osthd = apr_os_thread_current();
> >

Regards;
Yann.

Re: svn commit: r1902909 - /httpd/httpd/trunk/server/util.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 7/21/22 1:21 PM, ylavic@apache.org wrote:
> Author: ylavic
> Date: Thu Jul 21 11:21:30 2022
> New Revision: 1902909
> 
> URL: http://svn.apache.org/viewvc?rev=1902909&view=rev
> Log:
> core: Follow up to r1902728 and r1902906: simplify for APR-1.8+.
> 
> apr_threadattr_max_free_set() is now in APR-1.8.x.
> 
> 
> Modified:
>     httpd/httpd/trunk/server/util.c
> 
> Modified: httpd/httpd/trunk/server/util.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1902909&r1=1902908&r2=1902909&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/util.c (original)
> +++ httpd/httpd/trunk/server/util.c Thu Jul 21 11:21:30 2022

> @@ -3355,19 +3355,6 @@ AP_DECLARE(apr_status_t) ap_thread_main_
>          return rv;
>      }
>  
> -#if APR_VERSION_AT_LEAST(1,8,0) && !APR_VERSION_AT_LEAST(2,0,0)
> -    /* Don't let the thread's pool allocator with no limits, though there
> -     * is possibly no allocator with APR <= 1.7 and APR_POOL_DEBUG.
> -     */
> -    {
> -        apr_pool_t *tp = apr_thread_pool_get(*thread);
> -        apr_allocator_t *ta = apr_pool_allocator_get(tp);
> -        if (ta) {
> -            apr_allocator_max_free_set(ta, ap_max_mem_free);
> -        }
> -    }
> -#endif
> -

Why don't we do the above for APR <= 1.7? The code is now NULL safe for APR_POOL_DEBUG.

>      apr_pool_cleanup_register(pool, *thread, main_thread_cleanup,
>                                apr_pool_cleanup_null);
>      return APR_SUCCESS;
> @@ -3398,12 +3385,12 @@ AP_DECLARE(apr_status_t) ap_thread_curre
>              abort_fn(rv);
>          return rv;
>      }
> +    apr_allocator_max_free_set(ta, ap_max_mem_free);
>      rv = apr_pool_create_unmanaged_ex(&p, abort_fn, ta);
>      if (rv != APR_SUCCESS) {
>          return rv;
>      }
>      /* Don't let the thread's pool allocator with no limits */

The comment should move as well.

> -    apr_allocator_max_free_set(ta, ap_max_mem_free);
>      apr_allocator_owner_set(ta, p);
>  
>      osthd = apr_os_thread_current();
> 
> 
> 

Regards

RĂ¼diger