diff --git a/rpc/transport/http2_server_transport.go b/rpc/transport/http2_server_transport.go index ce793d287..f7058a5b6 100644 --- a/rpc/transport/http2_server_transport.go +++ b/rpc/transport/http2_server_transport.go @@ -156,7 +156,7 @@ func (t *http2Server) operateHeaders(hDec *hpackDecoder, s *Stream, frame header s.windowHandler = func(n int) { t.addRecvQuota(s, n) } - if hDec.state.timeout > 0 { + if hDec.state.timeoutSet { s.ctx, s.cancel = context.WithTimeout(context.TODO(), hDec.state.timeout) } else { s.ctx, s.cancel = context.WithCancel(context.TODO()) @@ -426,6 +426,7 @@ func (t *http2Server) WriteStatus(s *Stream, statusCode codes.Code, statusDesc s } s.mu.RUnlock() if _, err := wait(s.ctx, t.shutdownChan, t.writableChan); err != nil { + // TODO(zhaoq): Print some errors using glog, e.g., glog.V(1). return err } t.hBuf.Reset() diff --git a/rpc/transport/http_util.go b/rpc/transport/http_util.go index 33a17a1d6..d2c9356bf 100644 --- a/rpc/transport/http_util.go +++ b/rpc/transport/http_util.go @@ -87,8 +87,9 @@ type decodeState struct { statusCode codes.Code statusDesc string // Server side only fields. - timeout time.Duration - method string + timeoutSet bool + timeout time.Duration + method string // key-value metadata map from the peer. mdata map[string]string } @@ -144,6 +145,7 @@ func newHPACKDecoder() *hpackDecoder { case "grpc-message": d.state.statusDesc = f.Value case "grpc-timeout": + d.state.timeoutSet = true var err error d.state.timeout, err = timeoutDecode(f.Value) if err != nil {