internal: remove err from ClientTransport.GracefulClose (#2771)
This commit is contained in:
@ -794,21 +794,21 @@ func (t *http2Client) Close() error {
|
|||||||
// stream is closed. If there are no active streams, the transport is closed
|
// stream is closed. If there are no active streams, the transport is closed
|
||||||
// immediately. This does nothing if the transport is already draining or
|
// immediately. This does nothing if the transport is already draining or
|
||||||
// closing.
|
// closing.
|
||||||
func (t *http2Client) GracefulClose() error {
|
func (t *http2Client) GracefulClose() {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
// Make sure we move to draining only from active.
|
// Make sure we move to draining only from active.
|
||||||
if t.state == draining || t.state == closing {
|
if t.state == draining || t.state == closing {
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
t.state = draining
|
t.state = draining
|
||||||
active := len(t.activeStreams)
|
active := len(t.activeStreams)
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
if active == 0 {
|
if active == 0 {
|
||||||
return t.Close()
|
t.Close()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
t.controlBuf.put(&incomingGoAway{})
|
t.controlBuf.put(&incomingGoAway{})
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write formats the data into HTTP2 data frame(s) and sends it out. The caller
|
// Write formats the data into HTTP2 data frame(s) and sends it out. The caller
|
||||||
|
@ -583,7 +583,7 @@ type ClientTransport interface {
|
|||||||
// finished, the transport will close.
|
// finished, the transport will close.
|
||||||
//
|
//
|
||||||
// It does not block.
|
// It does not block.
|
||||||
GracefulClose() error
|
GracefulClose()
|
||||||
|
|
||||||
// Write sends the data for the given stream. A nil stream indicates
|
// Write sends the data for the given stream. A nil stream indicates
|
||||||
// the write is to be performed on the transport as a whole.
|
// the write is to be performed on the transport as a whole.
|
||||||
|
@ -1130,9 +1130,7 @@ func TestGracefulClose(t *testing.T) {
|
|||||||
if _, err := s.Read(recvMsg); err != nil {
|
if _, err := s.Read(recvMsg); err != nil {
|
||||||
t.Fatalf("Error while reading: %v", err)
|
t.Fatalf("Error while reading: %v", err)
|
||||||
}
|
}
|
||||||
if err = ct.GracefulClose(); err != nil {
|
ct.GracefulClose()
|
||||||
t.Fatalf("GracefulClose() = %v, want <nil>", err)
|
|
||||||
}
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
// Expect the failure for all the follow-up streams because ct has been closed gracefully.
|
// Expect the failure for all the follow-up streams because ct has been closed gracefully.
|
||||||
for i := 0; i < 200; i++ {
|
for i := 0; i < 200; i++ {
|
||||||
|
Reference in New Issue
Block a user