From 5ae93a9d0ebe90ec64ea9051a9f22f270f2c221f Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 15 Apr 2016 11:54:48 -0700 Subject: [PATCH] Addressed the comments --- transport/control.go | 2 +- transport/http2_client.go | 4 ++-- transport/http2_server.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/transport/control.go b/transport/control.go index f6da0ce3..7e9bdf33 100644 --- a/transport/control.go +++ b/transport/control.go @@ -201,7 +201,7 @@ func (f *inFlow) onRead(n uint32) uint32 { return 0 } -func (f *inFlow) getPendingData() uint32 { +func (f *inFlow) resetPendingData() uint32 { f.mu.Lock() defer f.mu.Unlock() n := f.pendingData diff --git a/transport/http2_client.go b/transport/http2_client.go index 69288181..8fc6ed0d 100644 --- a/transport/http2_client.go +++ b/transport/http2_client.go @@ -400,7 +400,7 @@ func (t *http2Client) CloseStream(s *Stream, err error) { // other goroutines. s.cancel() s.mu.Lock() - if q := s.fc.getPendingData(); q > 0 { + if q := s.fc.resetPendingData(); q > 0 { if n := t.fc.onRead(q); n > 0 { t.controlBuf.put(&windowUpdate{0, n}) } @@ -579,12 +579,12 @@ func (t *http2Client) updateWindow(s *Stream, n uint32) { } func (t *http2Client) handleData(f *http2.DataFrame) { - // Select the right stream to dispatch. size := len(f.Data()) if err := t.fc.onData(uint32(size)); err != nil { t.notifyError(ConnectionErrorf("%v", err)) return } + // Select the right stream to dispatch. s, ok := t.getStream(f) if !ok { if w := t.fc.onRead(uint32(size)); w > 0 { diff --git a/transport/http2_server.go b/transport/http2_server.go index 6e0dce6d..df918d8d 100644 --- a/transport/http2_server.go +++ b/transport/http2_server.go @@ -312,13 +312,13 @@ func (t *http2Server) updateWindow(s *Stream, n uint32) { } func (t *http2Server) handleData(f *http2.DataFrame) { - // Select the right stream to dispatch. size := len(f.Data()) if err := t.fc.onData(uint32(size)); err != nil { grpclog.Printf("transport: http2Server %v", err) t.Close() return } + // Select the right stream to dispatch. s, ok := t.getStream(f) if !ok { if w := t.fc.onRead(uint32(size)); w > 0 { @@ -710,7 +710,7 @@ func (t *http2Server) closeStream(s *Stream) { // called to interrupt the potential blocking on other goroutines. s.cancel() s.mu.Lock() - if q := s.fc.getPendingData(); q > 0 { + if q := s.fc.resetPendingData(); q > 0 { if w := t.fc.onRead(q); w > 0 { t.controlBuf.put(&windowUpdate{0, w}) }