This commit is contained in:

committed by
Menghan Li

parent
1c69e4cae0
commit
135247d85c
@ -179,12 +179,19 @@ func (a strAddr) String() string { return string(a) }
|
|||||||
|
|
||||||
// do runs fn in the ServeHTTP goroutine.
|
// do runs fn in the ServeHTTP goroutine.
|
||||||
func (ht *serverHandlerTransport) do(fn func()) error {
|
func (ht *serverHandlerTransport) do(fn func()) error {
|
||||||
|
// Avoid a panic writing to closed channel. Imperfect but maybe good enough.
|
||||||
|
select {
|
||||||
|
case <-ht.closedCh:
|
||||||
|
return ErrConnClosing
|
||||||
|
default:
|
||||||
select {
|
select {
|
||||||
case ht.writes <- fn:
|
case ht.writes <- fn:
|
||||||
return nil
|
return nil
|
||||||
case <-ht.closedCh:
|
case <-ht.closedCh:
|
||||||
return ErrConnClosing
|
return ErrConnClosing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ht *serverHandlerTransport) WriteStatus(s *Stream, st *status.Status) error {
|
func (ht *serverHandlerTransport) WriteStatus(s *Stream, st *status.Status) error {
|
||||||
|
Reference in New Issue
Block a user