apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignaz Birnstingl <ign...@gmail.com>
Subject Re: Fwd: [PATCH] apr_pstrdup value returned by apr_env_get
Date Tue, 13 Sep 2011 12:37:35 GMT

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().


2011/9/13 Bojan Smojver <bojan@rexursive.com>:
> ------- Original message -------
>> From: Ignaz Birnstingl <ignazb@gmail.com>
>> 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

View raw message