fix: list could lock if an error ocurred#167
Open
guilhem wants to merge 1 commit intodanielfoehrKn:masterfrom
Open
fix: list could lock if an error ocurred#167guilhem wants to merge 1 commit intodanielfoehrKn:masterfrom
guilhem wants to merge 1 commit intodanielfoehrKn:masterfrom
Conversation
|
|
||
| resultChannel := make(chan DiscoveredContext) | ||
| wgResultChannel := sync.WaitGroup{} | ||
| wgResultChannel.Add(len(stores)) |
Owner
There was a problem hiding this comment.
Now that we don't have the wait counter set up here any more, can we still call waitGroup.done() here when we read from the index? Looks to me like we wouldn't have a corresponding Add() any more.
Contributor
Author
There was a problem hiding this comment.
I'm not sure to understand where to .done() ^^
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes changes to the
DoSearchfunction in thepkg/search.gofile to improve the handling of the wait group for the result channel. The most important changes include moving the addition of the wait group counter to inside the goroutine and ensuring the counter is decremented with adeferstatement.Improvements to
DoSearchfunction:pkg/search.go: MovedwgResultChannel.Add(1)inside the loop to ensure it is called for each store in the goroutine.pkg/search.go: Addeddefer wgResultChannel.Done()at the beginning of the goroutine to ensure the counter is decremented when the goroutine completes.pkg/search.go: Removed the call towgResultChannel.Done()from the end of the goroutine as it is now handled by thedeferstatement.