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

Fix potential goroutine leaks #3170

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agent/acs/client/acs_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ func testCS(conn *mock_wsconn.MockWebsocketConn) wsclient.ClientServer {

// TODO: replace with gomock
func startMockAcsServer(t *testing.T, closeWS <-chan bool) (*httptest.Server, chan<- string, <-chan string, <-chan error, error) {
serverChan := make(chan string)
requestsChan := make(chan string)
errChan := make(chan error)
serverChan := make(chan string, 1)
requestsChan := make(chan string, 1)
errChan := make(chan error, 1)

upgrader := websocket.Upgrader{ReadBufferSize: 1024, WriteBufferSize: 1024}
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
6 changes: 2 additions & 4 deletions agent/acs/handler/acs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,10 @@ func NewSession(
func (acsSession *session) Start() error {
// connectToACS channel is used to indicate the intent to connect to ACS
// It's processed by the select loop to connect to ACS
connectToACS := make(chan struct{})
connectToACS := make(chan struct{}, 1)
// This is required to trigger the first connection to ACS. Subsequent
// connections are triggered by the handleACSError() method
go func() {
connectToACS <- struct{}{}
}()
connectToACS <- struct{}{}
for {
select {
case <-connectToACS:
Expand Down
2 changes: 1 addition & 1 deletion agent/tcs/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func startSession(
client.AddRequestHandler(ackPublishHealthMetricHandler(timer))
client.AddRequestHandler(ackPublishInstanceStatusHandler(timer))
client.SetAnyRequestHandler(anyMessageHandler(client))
serveC := make(chan error)
serveC := make(chan error, 1)
go func() {
serveC <- client.Serve()
}()
Expand Down