Since there are only two go routines, a slice of length 2 is used to store errors. After wg.Wait() the errors are combined and returned.
Motivation and Context
In the previous implementation, when both the read and write go routines has an error, there were no guarantees that the errors slice gets populated with two errors. The go routine processing the errChannel may not have had the opportunity to process the second error when wg.Wait unblocks.
How Has This Been Tested?
Unit tests were added to test the different error cases.
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
Checklist:
[x] My code follows the code style of this project.
Signed-off-by: Thomas Fan thomasjpfan@gmail.com
Fixes bug in
pipeToProcess
when recording errors.Description
Since there are only two go routines, a slice of length 2 is used to store errors. After
wg.Wait()
the errors are combined and returned.Motivation and Context
In the previous implementation, when both the read and write go routines has an error, there were no guarantees that the
errors
slice gets populated with two errors. The go routine processing theerrChannel
may not have had the opportunity to process the second error whenwg.Wait
unblocks.How Has This Been Tested?
Unit tests were added to test the different error cases.
Types of changes
Checklist:
git commit -s