summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Khmelnitsky <akhmelnitsky@vmware.com>2017-06-14 11:39:36 -0700
committerAnna Khmelnitsky <akhmelnitsky@vmware.com>2017-06-14 11:56:16 -0700
commit83a6e7fc064d2db848072c4fca5b87b85e877ed8 (patch)
treecc6cd347bb53c275dc36a267fd94c943d35adf97
parent7832618c4356d01a8c8113729568807f9a0d8570 (diff)
NSXv3: Race condition fix for cert provider
Refcount initialization needs to be under lock Change-Id: I27ee0161bfe2357c1c7acfb34ac58af30541cf8d
Notes
Notes (review): Code-Review+2: Tong Liu <tongl@vmware.com> Verified+1: VMware NSX CI Workflow+1: Tong Liu <tongl@vmware.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 16 Jun 2017 17:15:04 +0000 Reviewed-on: https://review.openstack.org/474319 Project: openstack/vmware-nsx Branch: refs/heads/stable/ocata
-rw-r--r--vmware_nsx/plugins/nsx_v3/utils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/vmware_nsx/plugins/nsx_v3/utils.py b/vmware_nsx/plugins/nsx_v3/utils.py
index 09748e0..e1641ec 100644
--- a/vmware_nsx/plugins/nsx_v3/utils.py
+++ b/vmware_nsx/plugins/nsx_v3/utils.py
@@ -54,7 +54,11 @@ class DbCertProvider(client_cert.ClientCertProvider):
54 # Such collisions are handled with refcount and locking. 54 # Such collisions are handled with refcount and locking.
55 super(DbCertProvider, self).__init__(None) 55 super(DbCertProvider, self).__init__(None)
56 random.seed() 56 random.seed()
57 self.refcount = 0 57
58 with self.lock:
59 # Initialize refcount if other threads did not do it already
60 if not hasattr(self, 'refcount'):
61 self.refcount = 0
58 62
59 def _check_expiration(self, expires_in_days): 63 def _check_expiration(self, expires_in_days):
60 if expires_in_days > self.EXPIRATION_ALERT_DAYS: 64 if expires_in_days > self.EXPIRATION_ALERT_DAYS: