The question was due to a typo in a hastily written description;

At 08:55 PM 1/8/2004, Donald Doane wrote:
>The following comment is from apr_lib.h:
>
> * apr_vformatter does not call out to any other code, it is entirely
> * self-contained.  This allows the callers to do things which are
> * otherwise "unsafe".  For example, apr_psprintf uses the "scratch"
> * space at the unallocated end of a block, and doesn't actually
> * complete the allocation until apr_vformatter returns.  apr_psprintf
> * would be completely broken if apr_vformatter were to call anything
> * that used a apr_pool_t.  Similarly http_bprintf() uses the "scratch"

s/used a apr_pool_t/used this pool/

> * space at the end of its output buffer, and doesn't actually note
> * that the space is in use until it either has to flush the buffer
> * or until apr_vformatter returns.
>
>
>
>>>Donald Doane wrote:
>>>>>
>>>>>
>>>>>
>>>>>Can someone please confirm whether or not "apr_psprintf" is thread safe.

So the answer is yes, provided that each thread has it's
own pool, which is the only sane application design.
Apache httpd allocates one pool per thread for each 
worker, from which the connection and request pools are
all created.  If the application you are concerned about
does the same you are safe.

Of course separate pools per thread also eliminates alot
of mutex protection on the allocator, which is a very good
thing for performance.

Bill





Reply via email to