apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Martin <phi...@codematters.co.uk>
Subject Re: apr_palloc is not thread safe
Date Thu, 30 May 2013 09:21:34 GMT
TROY.LIU 劉春偉 <TROY.LIU@DELTAWW.COM.CN> writes:

>   In our practice, we found two threads get same address returned by
>   apr_palloc. It will happen about one hour later after our server
>   starts.  We are using apr 1.4.5, the issue still exists in the
>   latest subversion.

>From apr_pools.h:

 * Note that most operations on pools are not thread-safe: a single pool
 * should only be accessed by a single thread at any given time. The one
 * exception to this rule is creating a subpool of a given pool: one or more
 * threads can safely create subpools at the same time that another thread
 * accesses the parent pool.

The pool system allows multiple threads to use multiple pools.  There is
no point trying to make apr_palloc "thread-safe" as the API is not
designed to work that way.  Even if apr_palloc was "thread-safe" how
would apr_pool_clear work?

A related discussion:

http://mail-archives.apache.org/mod_mbox/apr-dev/201304.mbox/%3C792240597.462741.1366211671567.JavaMail.root@brainsware.org%3E

-- 
Philip

Mime
View raw message