Skip to content

Commit 6ce5c19

Browse files
chore: reposition close of update channel
1 parent 3e50965 commit 6ce5c19

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

agent/agentcontainers/api.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,6 @@ func (api *API) watchContainers(rw http.ResponseWriter, r *http.Request) {
570570
defer encoder.Close(websocket.StatusNormalClosure)
571571

572572
updateCh := make(chan struct{}, 1)
573-
defer func() {
574-
api.mu.Lock()
575-
close(updateCh)
576-
api.mu.Unlock()
577-
}()
578573

579574
api.mu.Lock()
580575
api.updateChans = append(api.updateChans, updateCh)
@@ -585,6 +580,7 @@ func (api *API) watchContainers(rw http.ResponseWriter, r *http.Request) {
585580
api.updateChans = slices.DeleteFunc(api.updateChans, func(ch chan struct{}) bool {
586581
return ch == updateCh
587582
})
583+
close(updateCh)
588584
api.mu.Unlock()
589585
}()
590586

0 commit comments

Comments
 (0)