apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TROY.LIU 劉春偉 <TROY....@DELTAWW.COM.CN>
Subject RE: apr_palloc is not thread safe
Date Fri, 31 May 2013 04:15:53 GMT
Thanks for reply, I got it.  Now the problem is my APIs does not expose apr_pool_t to user
like apr,  so my APIs are not thread safe.

Best Regards
Chunwei Liu

-----Original Message-----
From: Philip Martin [mailto:codematters@ntlworld.com] On Behalf Of Philip Martin
Sent: Thursday, May 30, 2013 17:22 troy
To: TROY.LIU 劉春偉
Cc: dev@apr.apache.org; modules-dev@httpd.apache.org
Subject: Re: apr_palloc is not thread safe

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

*************************************************************************
This email message, including any attachments, is for the sole
use of the intended recipient(s) and may contain confidential and
privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply e-mail and destroy all copies of the original
message. [Delta Electronics, INC. China]
*************************************************************************
Mime
View raw message