integration: Code cleanup
Don't close channel to avoid potential write-after-close. Use time.After instead of time.NewTimer
This commit is contained in:
parent
e8053ac931
commit
09939cf6bc
|
@ -111,8 +111,6 @@ func (st *serverTester) Close() {
|
||||||
if st.ts != nil {
|
if st.ts != nil {
|
||||||
st.ts.Close()
|
st.ts.Close()
|
||||||
}
|
}
|
||||||
close(st.frCh)
|
|
||||||
close(st.errCh)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *serverTester) readFrame() (http2.Frame, error) {
|
func (st *serverTester) readFrame() (http2.Frame, error) {
|
||||||
|
@ -125,14 +123,12 @@ func (st *serverTester) readFrame() (http2.Frame, error) {
|
||||||
st.frCh <- f
|
st.frCh <- f
|
||||||
}()
|
}()
|
||||||
|
|
||||||
t := time.NewTimer(2 * time.Second)
|
|
||||||
defer t.Stop()
|
|
||||||
select {
|
select {
|
||||||
case f := <-st.frCh:
|
case f := <-st.frCh:
|
||||||
return f, nil
|
return f, nil
|
||||||
case err := <-st.errCh:
|
case err := <-st.errCh:
|
||||||
return nil, err
|
return nil, err
|
||||||
case <-t.C:
|
case <-time.After(2 * time.Second):
|
||||||
return nil, errors.New("timeout waiting for frame")
|
return nil, errors.New("timeout waiting for frame")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue