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:
Tatsuhiro Tsujikawa 2015-01-19 21:18:35 +09:00
parent e8053ac931
commit 09939cf6bc
1 changed files with 1 additions and 5 deletions

View File

@ -111,8 +111,6 @@ func (st *serverTester) Close() {
if st.ts != nil {
st.ts.Close()
}
close(st.frCh)
close(st.errCh)
}
func (st *serverTester) readFrame() (http2.Frame, error) {
@ -125,14 +123,12 @@ func (st *serverTester) readFrame() (http2.Frame, error) {
st.frCh <- f
}()
t := time.NewTimer(2 * time.Second)
defer t.Stop()
select {
case f := <-st.frCh:
return f, nil
case err := <-st.errCh:
return nil, err
case <-t.C:
case <-time.After(2 * time.Second):
return nil, errors.New("timeout waiting for frame")
}
}