fix a counting error in the previous commit

This commit is contained in:
iamqizhao
2016-07-29 17:36:12 -07:00
parent 77ec0f0a5b
commit 5093059db2

View File

@ -111,24 +111,26 @@ func (h *testStreamHandler) handleStreamMisbehave(t *testing.T, s *Stream) {
if !ok { if !ok {
t.Fatalf("Failed to convert %v to *http2Server", s.ServerTransport()) t.Fatalf("Failed to convert %v to *http2Server", s.ServerTransport())
} }
var end, size int var end int
if s.Method() == "foo.MaxFrame" { if s.Method() == "foo.Connection" {
size = http2MaxFrameLen - 1 // Violate connection level flow control window of client but do not
// violate any stream level windows.
end = initialWindowSize end = initialWindowSize
} else { } else {
size = 1 // Violate stream level flow control window of client.
end = initialWindowSize + 1 end = initialWindowSize + 1
} }
// Violate the client side stream/connection flow control window. // Violate the client side stream/connection flow control window.
var sent int var sent int
p := make([]byte, 1)
for sent < end { for sent < end {
<-conn.writableChan <-conn.writableChan
if err := conn.framer.writeData(true, s.id, false, make([]byte, size)); err != nil { if err := conn.framer.writeData(true, s.id, false, p); err != nil {
conn.writableChan <- 0 conn.writableChan <- 0
break break
} }
conn.writableChan <- 0 conn.writableChan <- 0
sent += size sent += len(p)
} }
} }
@ -664,7 +666,7 @@ func TestClientWithMisbehavedServer(t *testing.T) {
server, ct := setUp(t, 0, math.MaxUint32, misbehaved) server, ct := setUp(t, 0, math.MaxUint32, misbehaved)
callHdr := &CallHdr{ callHdr := &CallHdr{
Host: "localhost", Host: "localhost",
Method: "foo", Method: "foo.Stream",
} }
conn, ok := ct.(*http2Client) conn, ok := ct.(*http2Client)
if !ok { if !ok {
@ -700,7 +702,7 @@ func TestClientWithMisbehavedServer(t *testing.T) {
// //
// Generate enough streams to drain the connection window. Make the server flood the traffic // Generate enough streams to drain the connection window. Make the server flood the traffic
// to violate flow control window size of the connection. // to violate flow control window size of the connection.
callHdr.Method = "foo.MaxFrame" callHdr.Method = "foo.Connection"
for i := 0; i < int(initialConnWindowSize/initialWindowSize+10); i++ { for i := 0; i < int(initialConnWindowSize/initialWindowSize+10); i++ {
s, err := ct.NewStream(context.Background(), callHdr) s, err := ct.NewStream(context.Background(), callHdr)
if err != nil { if err != nil {