Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
transport: Fix double lock and state overwrite on disconnected peers (#…
…179) This PR fixes an issue where the secondary connection is rejected because it has a different connection ID. The issue comes from `fn dial_address` which can overwrite the state of a disconnected peer with in-flight dial requests. ### High level repro case - T0: dial_address 1 - T1: dial_address 2 which overwrites address 1 - T2: dialed address 1 responds with a connection - T3: connection is rejected While at it, this PR also: - removes the need to double lock the peer state (once to read and once to write) - enforces connection ID checks on dial records in `on_dial_failure` - adjust the repro case from #176 for the fix ### Detailed repro case - T0: Dial address A connection ID 1 -> State : Dialing { in-flight-1 } - T1: Connection is established by remote address C connection ID 3 -> State : Connected { in-flight-dial 1 } - T2: Closed connection established in T2 -> State : Disconnected { in-flight-dial 1} // This is where the state was wrongfully overwritten - T3: Dial address B connection ID 2 -> State: Dialing { in-flight-2 } - T4: Connection is established by remote address C connection ID 3 -> State : Connected { in-flight-dial 2 } // The issue was detected here - T5: Dial from T0 receives a response however it expects in-flight-dial 1 and the state has in-flight-dial 2 Closes: #172 --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
- Loading branch information