document the usage of errCh

Kubernetes-commit: 5809b6a4282f7ce58e0d815d9326289a8ee7ddb6
This commit is contained in:
Haowei Cai 2019-03-28 16:55:03 -07:00 committed by Kubernetes Publisher
parent 4a7b414073
commit 278cabecf3
1 changed files with 5 additions and 3 deletions

View File

@ -92,7 +92,8 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
errCh := make(chan interface{})
// resultCh is used as both errCh and stopCh
resultCh := make(chan interface{})
tw := newTimeoutWriter(w)
go func() {
defer func() {
@ -103,12 +104,13 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
buf = buf[:runtime.Stack(buf, false)]
err = fmt.Sprintf("%v\n%s", err, buf)
}
errCh <- err
resultCh <- err
}()
t.handler.ServeHTTP(tw, r)
}()
select {
case err := <-errCh:
case err := <-resultCh:
// panic if error occurs; stop otherwise
if err != nil {
panic(err)
}