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

network: fix possible deadlock in DefaultDiscovery #741

Merged
merged 1 commit into from
Mar 10, 2020
Merged

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Mar 10, 2020

Why a deadlock can occur:

  1. (*DefaultDiscovery).run() has a for loop over requestCh channel.
  2. (*DefaultDiscovery).RequestRemote() send to this channel while holding a mutex.
  3. (*DefaultDiscovery).RegisterBadAddr() tries to take mutex for write.
  4. Second select-case can't take mutex for read because of (3).

Why a deadlock can occur:
1. (*DefaultDiscovery).run() has a for loop over requestCh channel.
2. (*DefaultDiscovery).RequestRemote() send to this channel while
    holding a mutex.
3. (*DefaultDiscovery).RegisterBadAddr() tries to take mutex for write.
4. Second select-case can't take mutex for read because of (3).
@codecov
Copy link

codecov bot commented Mar 10, 2020

Codecov Report

Merging #741 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #741   +/-   ##
=======================================
  Coverage   66.68%   66.68%           
=======================================
  Files         136      136           
  Lines       12269    12269           
=======================================
  Hits         8181     8181           
  Misses       3692     3692           
  Partials      396      396
Impacted Files Coverage Δ
pkg/network/discovery.go 98.14% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f1e8f6...b7dee15. Read the comment docs.

@roman-khimov roman-khimov added this to the v0.74.0 milestone Mar 10, 2020
@roman-khimov roman-khimov merged commit b7fa8dd into master Mar 10, 2020
@roman-khimov roman-khimov deleted the fix/network branch March 10, 2020 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants