mirror of https://github.com/grpc/grpc-go.git
Merge branch 'master' of https://github.com/grpc/grpc-go
This commit is contained in:
commit
bcbb6549ac
|
|
@ -820,8 +820,8 @@ func (s *Server) Stop() {
|
|||
// connections and RPCs and blocks until all the pending RPCs are finished.
|
||||
func (s *Server) GracefulStop() {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.drain == true || s.conns == nil {
|
||||
s.mu.Unlock()
|
||||
return
|
||||
}
|
||||
s.drain = true
|
||||
|
|
@ -840,7 +840,6 @@ func (s *Server) GracefulStop() {
|
|||
s.events.Finish()
|
||||
s.events = nil
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
|||
|
|
@ -239,6 +239,10 @@ func (t *http2Server) HandleStreams(handle func(*Stream)) {
|
|||
}
|
||||
|
||||
frame, err := t.framer.readFrame()
|
||||
if err == io.EOF || err == io.ErrUnexpectedEOF {
|
||||
t.Close()
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
grpclog.Printf("transport: http2Server.HandleStreams failed to read frame: %v", err)
|
||||
t.Close()
|
||||
|
|
@ -265,6 +269,10 @@ func (t *http2Server) HandleStreams(handle func(*Stream)) {
|
|||
t.controlBuf.put(&resetStream{se.StreamID, se.Code})
|
||||
continue
|
||||
}
|
||||
if err == io.EOF || err == io.ErrUnexpectedEOF {
|
||||
t.Close()
|
||||
return
|
||||
}
|
||||
grpclog.Printf("transport: http2Server.HandleStreams failed to read frame: %v", err)
|
||||
t.Close()
|
||||
return
|
||||
|
|
|
|||
|
|
@ -559,6 +559,12 @@ func wait(ctx context.Context, done, goAway, closing <-chan struct{}, proceed <-
|
|||
case <-closing:
|
||||
return 0, ErrConnClosing
|
||||
case i := <-proceed:
|
||||
// User cancellation has precedence.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return 0, ContextErr(ctx.Err())
|
||||
default:
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -553,6 +553,7 @@ func TestServerContextCanceledOnClosedConnection(t *testing.T) {
|
|||
case <-time.After(5 * time.Second):
|
||||
t.Fatalf("Failed to cancel the context of the sever side stream.")
|
||||
}
|
||||
server.stop()
|
||||
}
|
||||
|
||||
func TestServerWithMisbehavedClient(t *testing.T) {
|
||||
|
|
@ -732,7 +733,7 @@ func TestEncodingRequiredStatus(t *testing.T) {
|
|||
Last: true,
|
||||
Delay: false,
|
||||
}
|
||||
if err := ct.Write(s, expectedRequest, &opts); err != nil {
|
||||
if err := ct.Write(s, expectedRequest, &opts); err != nil || err == io.EOF {
|
||||
t.Fatalf("Failed to write the request: %v", err)
|
||||
}
|
||||
p := make([]byte, http2MaxFrameLen)
|
||||
|
|
|
|||
Loading…
Reference in New Issue