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

swarm/network: fix data race in fetcher_test.go #18469

Commits on Jan 17, 2019

  1. swarm/network: fix typos in fetcher.go

    Ferenc Szabo committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    bad8c1e View commit details
    Browse the repository at this point in the history
  2. swarm/network: fix data race in fetcher_test.go

    Problem:
    Let's say TestA() and TestB() was started right after each other.
    TestA() called `go Fetcher.run(ctx)` (read: searchTimeout), on test
    completion the context was cancelled, but the test did not wait for
    goroutine termination. Test(B) started by modifying searchTimeout
    (write).
    
    Solution: Let's just store searchTimeout on the Fetcher struct and
    change the package var (default) to const (thread-safe).
    
    Alternative (almost) solution:
    The above could have been solved by (little ugly, more complex)
    waitGroups. However that would have not work for TestFetcherFactory.
    As fetcherFactory.New()starts a goroutine inside it's body without
    providing a way for clear termination. (We did not want to modify the
    interface for this one, as we think the unclean termination does not
    cause a problem in this case in production.)
    
    fixes #1109
    Ferenc Szabo committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    13d7b59 View commit details
    Browse the repository at this point in the history