• Julien Muchembled's avatar
    connection: make close always call handler (connectionClosed or connectionFailed) · 4b6c1387
    Julien Muchembled authored
    Main reason is that it's difficult to know in advance which side really closes
    the connection. Network events can be chaotic and this could lead to many race
    conditions.
    Thus, handler can be used to update any database that is somewhat redundant
    to the connection status, i.e. node status usually. Safely and less duplicated
    code.
    
    This change is motivated by recurrent random failures during election.
    An example of race condition was that 2 fully connected master could close the
    extra connection (the primary -> secondary one) at the same time.
    
    In order to stabilize lower-level code and start with reliable election process,
    code has also been simplified to not care about node states. All connections
    without exception are closed at the end of the election and states are then
    updated 1 by 1 by identification handler.
    Note that during election, there may be 2 connection per node, which makes
    difficult to update node states by connectionFailed/connectionClosed events.
    
    timeoutExpired & peerBroken are dropped as they are unused for the moment.
    A new API should be designed so that connectionClosed know the reason of the
    close.
    BROKEN state becomes unused.
    
    git-svn-id: https://svn.erp5.org/repos/neo/trunk@2732 71dcc9de-d417-0410-9af5-da40c76e7ee4
    4b6c1387
testVerification.py 9.41 KB