Fix: Potential Goroutine Leak Due to Un-buffered Channel #3712
+4
−4
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.
What does this pull request do? Explain your changes. (required)
This PR is intended to fix the potential goroutine leak issue. In the
StartLivepeer
function, there is a potential goroutine leak caused by sending to an un-buffered channel. The channelsec
,tc
, andwc
are un-buffered, which can lead to a situation where the goroutine blocks indefinitely if thectx.Done()
branch wins the race. This results in leaked resources as the goroutine is never able to complete its execution.The same issue exists in the
getOrchestratorInfo
function fromserver/router.go
, where an un-buffered channelinfoCh
is used to receive orchestrator informationSpecific updates (required)
To prevent the potential goroutine leak, this PR make the channels buffered by specifying a buffer size of 1.
How did you test each of these updates (required)
Does this pull request close any open issues?
No
Checklist:
make
runs successfully./test.sh
pass