Commit a01d9c25 authored by Vincent Pelletier's avatar Vincent Pelletier

Request identification only if needed.

Also, only check if connector is opened when needed, and use new "isClosed"
method on connection.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2026 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c3d6e9a4
......@@ -111,14 +111,6 @@ class ClientElectionHandler(MasterHandler):
app.negotiating_master_node_set.discard(conn.getAddress())
def answerPrimary(self, conn, primary_uuid, known_master_list):
if conn.getConnector() is None:
# Connection can be closed by peer after he sent
# AnswerPrimary if he finds the primary master before we
# give him our UUID.
# The connection gets closed before this message gets processed
# because this message might have been queued, but connection
# interruption takes effect as soon as received.
return
app = self.app
# Register new master nodes.
for address, uuid in known_master_list:
......@@ -155,13 +147,32 @@ class ClientElectionHandler(MasterHandler):
app.unconnected_master_node_set.clear()
app.negotiating_master_node_set.clear()
# Request a node identification.
conn.ask(Packets.RequestIdentification(
NodeTypes.MASTER,
app.uuid,
app.server,
app.name
))
if (primary_uuid is None or conn.getUUID() == primary_uuid) and \
not conn.isClosed():
# Request a node identification.
# There are 3 cases here:
# - Peer doesn't know primary node
# We must ask its identification so we exchange our uuids, to
# know which of us is secondary.
# - Peer knows primary node
# - He is the primary
# We must ask its identification, as part of the normal
# connection process
# - He is not the primary
# We don't need to ask its identification, as we will close
# this connection anyway (exiting election).
# Also, connection can be closed by peer after he sent
# AnswerPrimary if he finds the primary master before we
# give him our UUID.
# The connection gets closed before this message gets processed
# because this message might have been queued, but connection
# interruption takes effect as soon as received.
conn.ask(Packets.RequestIdentification(
NodeTypes.MASTER,
app.uuid,
app.server,
app.name
))
class ServerElectionHandler(MasterHandler):
......
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