Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f28220

Browse files
authored
fix(coderd): add timeout to websocket waitgroup on shutdown (#12754)
1 parentcfb484f commit5f28220

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

‎coderd/coderd.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,23 @@ func (api *API) Close() error {
12851285
api.derpCloseFunc()
12861286
}
12871287

1288-
api.WebsocketWaitMutex.Lock()
1289-
api.WebsocketWaitGroup.Wait()
1290-
api.WebsocketWaitMutex.Unlock()
1288+
wsDone:=make(chanstruct{})
1289+
timer:=time.NewTimer(10*time.Second)
1290+
defertimer.Stop()
1291+
gofunc() {
1292+
api.WebsocketWaitMutex.Lock()
1293+
deferapi.WebsocketWaitMutex.Unlock()
1294+
api.WebsocketWaitGroup.Wait()
1295+
close(wsDone)
1296+
}()
1297+
// This will technically leak the above func if the timer fires, but this is
1298+
// maintly a last ditch effort to un-stuck coderd on shutdown. This
1299+
// shouldn't affect tests at all.
1300+
select {
1301+
case<-wsDone:
1302+
case<-timer.C:
1303+
api.Logger.Warn(api.ctx,"websocket shutdown timed out after 10 seconds")
1304+
}
12911305

12921306
api.dbRolluper.Close()
12931307
api.metricsCache.Close()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp