-
Notifications
You must be signed in to change notification settings - Fork 20.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ethersphere/swarm#1109
- Loading branch information
Ferenc Szabo
committed
Jan 17, 2019
1 parent
bad8c1e
commit 13d7b59
Showing
2 changed files
with
16 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters