Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3374212

Browse files
committed
Fix race with adding to wait group
1 parent 00d4326 commit 3374212

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

coderd/provisionerdaemons.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func (api *api) provisionerDaemons(rw http.ResponseWriter, r *http.Request) {
5252

5353
// Serves the provisioner daemon protobuf API over a WebSocket.
5454
func (api *api) provisionerDaemonsServe(rw http.ResponseWriter, r *http.Request) {
55+
api.websocketWaitGroup.Add(1)
56+
defer api.websocketWaitGroup.Done()
57+
5558
conn, err := websocket.Accept(rw, r, &websocket.AcceptOptions{
5659
// Need to disable compression to avoid a data-race.
5760
CompressionMode: websocket.CompressionDisabled,
@@ -62,8 +65,6 @@ func (api *api) provisionerDaemonsServe(rw http.ResponseWriter, r *http.Request)
6265
})
6366
return
6467
}
65-
api.websocketWaitGroup.Add(1)
66-
defer api.websocketWaitGroup.Done()
6768

6869
daemon, err := api.Database.InsertProvisionerDaemon(r.Context(), database.InsertProvisionerDaemonParams{
6970
ID: uuid.New(),

0 commit comments

Comments
 (0)