Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocols/identify: Fix race condition in discover_peer_after_disconnect #2744

Merged
merged 2 commits into from Jul 4, 2022

Commits on Jul 2, 2022

  1. protocols/identify: Fix race condition in discover_peer_after_disconnect

    **Summary** of the plot of the `discover_peer_after_disconnect` test:
    
    1. `swarm2` connects to `swarm1`.
    2. `swarm2` requests an identify response from `swarm1`.
    3. `swarm1` sends the response to `swarm2`.
    4. `swarm2` disconnects from `swarm1`.
    5. `swarm2` tries to disconnect.
    
    **Problem**
    
    `libp2p-identify` sets `KeepAlive::No` when it identified the remote. Thus `swarm1` might
    identify` `swarm2` before `swarm2` identified `swarm1`. `swarm1` then sets `KeepAlive::No` and thus closes the
    connection to `swarm2` before `swarm2` identified `swarm1`. In such case the unit test
    `discover_peer_after_disconnect hangs indefinitely.
    
    **Solution**
    
    Add an initial delay to `swarm1` requesting an identification from `swarm2`, thus ensuring `swarm2`
    is always able to identify `swarm1`.
    mxinden committed Jul 2, 2022
    Copy the full SHA
    1830877 View commit details
    Browse the repository at this point in the history

Commits on Jul 4, 2022

  1. Copy the full SHA
    116cdab View commit details
    Browse the repository at this point in the history