curl-library
Re: [PATCH] add some locking for thread-safety to NSS implementation
Date: Tue, 16 Sep 2008 14:05:10 -0700
On Tue, Sep 16, 2008 at 03:08:07PM -0400, Rob Crittenden wrote:
> Rob Crittenden wrote:
>> Add some locking around the initialized test to make it thread-safe.
>>
>> Make the code more aware of whether it has initialized NSS itself or
>> whether it was initialized in another library linked with libcurl.
>>
>> We would always shut down NSS during cleanup whether we initialized or
>> or not. Now we will only shut it down if libcurl initialized it.
>>
>> rob
>>
>
> Updated patch that fixes a mis-placed PR_Unlock() which could cause a hang.
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. Also, initialized should be made volatile.
>>> Dan
-- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has movedReceived on 2008-09-16