Browse Source

http2: prevent deadlock channel send in server Handler if client disappears

Noticed during a crash in earlier testing. This now matches all the
other channel sends, selecting on the serverConn's terminiation channel.

Change-Id: I27ad3f9fd2d61154a5b95da82735d34fc2cbbc0b
Reviewed-on: https://go-review.googlesource.com/16381
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Brad Fitzpatrick 10 years ago
parent
commit
0a9f6507bc
1 changed files with 4 additions and 1 deletions
  1. 4 1
      http2/server.go

+ 4 - 1
http2/server.go

@@ -1588,7 +1588,10 @@ type bodyReadMsg struct {
 // and schedules flow control tokens to be sent.
 func (sc *serverConn) noteBodyReadFromHandler(st *stream, n int) {
 	sc.serveG.checkNotOn() // NOT on
-	sc.bodyReadCh <- bodyReadMsg{st, n}
+	select {
+	case sc.bodyReadCh <- bodyReadMsg{st, n}:
+	case <-sc.doneServing:
+	}
 }
 
 func (sc *serverConn) noteBodyRead(st *stream, n int) {