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

Commit02861b4

Browse files
authored
Merge pull request#238 from nhooyr/dev
Fix deadlock introduced in v1.8.5
2 parents34417b2 +03cca81 commit02861b4

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎ci/all.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main() {
66

77
./ci/fmt.sh
88
./ci/lint.sh
9-
./ci/test.sh
9+
./ci/test.sh"$@"
1010
}
1111

1212
main"$@"

‎write.go‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,24 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
246246
iferr!=nil {
247247
return0,err
248248
}
249-
deferfunc() {
250-
// We leave it locked when writing the close frame to avoid
251-
// any other goroutine writing any other frame.
252-
ifopcode!=opClose {
253-
c.writeFrameMu.unlock()
249+
deferc.writeFrameMu.unlock()
250+
251+
// If the state says a close has already been written, we wait until
252+
// the connection is closed and return that error.
253+
//
254+
// However, if the frame being written is a close, that means its the close from
255+
// the state being set so we let it go through.
256+
c.closeMu.Lock()
257+
wroteClose:=c.wroteClose
258+
c.closeMu.Unlock()
259+
ifwroteClose&&opcode!=opClose {
260+
select {
261+
case<-ctx.Done():
262+
return0,ctx.Err()
263+
case<-c.closed:
264+
return0,c.closeErr
254265
}
255-
}()
266+
}
256267

257268
select {
258269
case<-c.closed:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp