mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 23:57:49 +00:00
document the usage of errCh
This commit is contained in:
parent
094938895a
commit
5809b6a428
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user