NSXv3: Race condition fix for cert provider

Refcount initialization needs to be under lock

Change-Id: I27ee0161bfe2357c1c7acfb34ac58af30541cf8d
This commit is contained in:
Anna Khmelnitsky 2017-06-14 11:39:36 -07:00
parent 7832618c43
commit 83a6e7fc06
1 changed files with 5 additions and 1 deletions

View File

@ -54,7 +54,11 @@ class DbCertProvider(client_cert.ClientCertProvider):
# Such collisions are handled with refcount and locking.
super(DbCertProvider, self).__init__(None)
random.seed()
self.refcount = 0
with self.lock:
# Initialize refcount if other threads did not do it already
if not hasattr(self, 'refcount'):
self.refcount = 0
def _check_expiration(self, expires_in_days):
if expires_in_days > self.EXPIRATION_ALERT_DAYS: