mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
errCh := make(chan interface{})
|
// resultCh is used as both errCh and stopCh
|
||||||
|
resultCh := make(chan interface{})
|
||||||
tw := newTimeoutWriter(w)
|
tw := newTimeoutWriter(w)
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -103,12 +104,13 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
buf = buf[:runtime.Stack(buf, false)]
|
buf = buf[:runtime.Stack(buf, false)]
|
||||||
err = fmt.Sprintf("%v\n%s", err, buf)
|
err = fmt.Sprintf("%v\n%s", err, buf)
|
||||||
}
|
}
|
||||||
errCh <- err
|
resultCh <- err
|
||||||
}()
|
}()
|
||||||
t.handler.ServeHTTP(tw, r)
|
t.handler.ServeHTTP(tw, r)
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case err := <-errCh:
|
case err := <-resultCh:
|
||||||
|
// panic if error occurs; stop otherwise
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user