cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 18 Sep 2008 14:11:06 +0200 (CEST)

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.

-- 
  / daniel.haxx.se
Received on 2008-09-18