apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Been <kbb...@gmail.com>
Subject thread safety of apr_initialize
Date Sun, 22 Sep 2013 02:06:47 GMT
I am considering using a library (serf) built on APR in my own library.
Since I'm writing a library, I can make no assumptions about what the
calling program does - it might have multiple threads started before it
calls my library, and some of those threads might be using APR.

My library can call apr_initialize, but I can't guarantee that it won't
conflict with another call to apr_initialize in some other thread that I
don't control.  Since apr_initialize doesn't seem to be thread safe, and I
don't want to put (what I consider to be) onerous requirements on the users
of my library, this effectively makes APR unusable for me.

So first, is my analysis correct?  And second, if it is, is there some good
reason that apr_initialize has not been made thread safe?  At first glance
I think simply making "initialized++" an atomic operation should do it, or
if not then making the whole function body a critical section.  I'd be
happy to work on a patch, but the fact that this hasn't been done makes me
suspect there must be a good reason for that.

Thanks for any help.


View raw message