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

Commit0db909c

Browse files
committed
fix: close pg PubSub listener to avoid race
1 parent5bfbf9f commit0db909c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎coderd/database/pubsub/pubsub.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,11 @@ func (p *pgPubsub) Publish(event string, message []byte) error {
239239

240240
// Close closes the pubsub instance.
241241
func (p*pgPubsub)Close()error {
242-
p.cancel()
242+
// canceling the context also causes the listener to be closed, so directly
243+
// close it before canceling the context to avoid the race. If we lost the
244+
// race we'd return an error about the listener already being closed.
243245
err:=p.pgListener.Close()
246+
p.cancel()
244247
<-p.listenDone
245248
returnerr
246249
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp