Bojan, I'm totally aware of that and that's what I said in previous mails. However there is IMHO no way to make this API thread-safe since it uses a non-thread-safe API in the first place. Suppose we would use internal serialization by using an APR mutex inside all APR environment functions, that would still not prevent some other thread from directly calling C's getenv().
-- Ignaz 2011/9/13 Bojan Smojver <[email protected]>: > ------- Original message ------- >> >> From: Ignaz Birnstingl <[email protected]> > >> Now if I use APR >> (pseudo code) >> char *foo = apr_env_get("foo"); >> char *bar = apr_env_get("bar"); >> if apr_env_get would pstrdup the string returned by getenv I could >> compare foo with bar, like this if (strcmp(foo, bar) == 0) ... > > That is not necessarily true either. Suppose another thread called > getenv("foo") just after getenv() and before strdup() in apr_env_get() of > your thread. You would then get "foo" in your copy as well, because you'd be > copying that same static buffer. > > -- > Bojan
