Commit 9ec55c99 authored by Vincent Pelletier's avatar Vincent Pelletier

Make _getMasterConnection lockless in best case.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1758 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 70284a0e
...@@ -216,14 +216,16 @@ class Application(object): ...@@ -216,14 +216,16 @@ class Application(object):
def _getMasterConnection(self): def _getMasterConnection(self):
""" Connect to the primary master node on demand """ """ Connect to the primary master node on demand """
# acquire the lock to allow only one thread to connect to the primary # acquire the lock to allow only one thread to connect to the primary
self._connecting_to_master_node_acquire() result = self.master_conn
try: if result is None:
if self.master_conn is None: self._connecting_to_master_node_acquire()
try:
self.new_oid_list = [] self.new_oid_list = []
self.master_conn = self._connectToPrimaryNode() result = self._connectToPrimaryNode()
return self.master_conn self.master_conn = result
finally: finally:
self._connecting_to_master_node_release() self._connecting_to_master_node_release()
return result
def _getPartitionTable(self): def _getPartitionTable(self):
""" Return the partition table manager, reconnect the PMN if needed """ """ Return the partition table manager, reconnect the PMN if needed """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment