internal: remove err from ClientTransport.GracefulClose (#2771)

This commit is contained in:
Jean de Klerk
2019-05-02 14:20:28 -06:00
committed by GitHub
parent 5ed5cbab96
commit a9408321c7
3 changed files with 6 additions and 8 deletions

View File

@ -794,21 +794,21 @@ func (t *http2Client) Close() error {
// stream is closed. If there are no active streams, the transport is closed
// immediately. This does nothing if the transport is already draining or
// closing.
func (t *http2Client) GracefulClose() error {
func (t *http2Client) GracefulClose() {
t.mu.Lock()
// Make sure we move to draining only from active.
if t.state == draining || t.state == closing {
t.mu.Unlock()
return nil
return
}
t.state = draining
active := len(t.activeStreams)
t.mu.Unlock()
if active == 0 {
return t.Close()
t.Close()
return
}
t.controlBuf.put(&incomingGoAway{})
return nil
}
// Write formats the data into HTTP2 data frame(s) and sends it out. The caller

View File

@ -583,7 +583,7 @@ type ClientTransport interface {
// finished, the transport will close.
//
// It does not block.
GracefulClose() error
GracefulClose()
// Write sends the data for the given stream. A nil stream indicates
// the write is to be performed on the transport as a whole.

View File

@ -1130,9 +1130,7 @@ func TestGracefulClose(t *testing.T) {
if _, err := s.Read(recvMsg); err != nil {
t.Fatalf("Error while reading: %v", err)
}
if err = ct.GracefulClose(); err != nil {
t.Fatalf("GracefulClose() = %v, want <nil>", err)
}
ct.GracefulClose()
var wg sync.WaitGroup
// Expect the failure for all the follow-up streams because ct has been closed gracefully.
for i := 0; i < 200; i++ {