cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH] add some locking for thread-safety to NSS implementation

From: Rob Crittenden <rcritten_at_redhat.com>
Date: Fri, 19 Sep 2008 17:06:40 -0400

Daniel Stenberg wrote:
> On Tue, 16 Sep 2008, Dan Fandrich wrote:
>
>> There looks to me like there's still a race condition in there. If a
>> thread switch occurs in Curl_nss_connect() in the "Unable to
>> initialize NSS database" error case after the lock is cleared but
>> before initialized is set to 0, another thread could to sneak in and
>> set initialized to 1 before the first thread sets it back to 0,
>> causing the next call to initialize NSS again.
>
> Right, shouldn't the variable be set to 0 before the unlock?
>
>> Also, initialized should be made volatile.
>
> It should most probably indeed, as I bet it can cause race condition
> problems otherwise as well.
>

Thanks for the feedback. New patch attached.

rob

Received on 2008-09-19