Merge branch 'master' of https://github.com/grpc/grpc-go
This commit is contained in:
@ -2219,8 +2219,8 @@ func testClientRequestBodyError_Cancel(t *testing.T, e env) {
|
|||||||
te.withServerTester(func(st *serverTester) {
|
te.withServerTester(func(st *serverTester) {
|
||||||
st.writeHeadersGRPC(1, "/grpc.testing.TestService/UnaryCall")
|
st.writeHeadersGRPC(1, "/grpc.testing.TestService/UnaryCall")
|
||||||
// Say we have 5 bytes coming, but cancel it instead.
|
// Say we have 5 bytes coming, but cancel it instead.
|
||||||
st.writeData(1, false, []byte{0, 0, 0, 0, 5})
|
|
||||||
st.writeRSTStream(1, http2.ErrCodeCancel)
|
st.writeRSTStream(1, http2.ErrCodeCancel)
|
||||||
|
st.writeData(1, false, []byte{0, 0, 0, 0, 5})
|
||||||
|
|
||||||
// Verify we didn't a call yet.
|
// Verify we didn't a call yet.
|
||||||
select {
|
select {
|
||||||
|
@ -559,12 +559,6 @@ func wait(ctx context.Context, done, goAway, closing <-chan struct{}, proceed <-
|
|||||||
case <-closing:
|
case <-closing:
|
||||||
return 0, ErrConnClosing
|
return 0, ErrConnClosing
|
||||||
case i := <-proceed:
|
case i := <-proceed:
|
||||||
// User cancellation has precedence.
|
|
||||||
select {
|
|
||||||
case <-ctx.Done():
|
|
||||||
return 0, ContextErr(ctx.Err())
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,20 +111,28 @@ 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())
|
||||||
}
|
}
|
||||||
size := 1
|
|
||||||
if s.Method() == "foo.MaxFrame" {
|
|
||||||
size = http2MaxFrameLen
|
|
||||||
}
|
|
||||||
// Drain the client side stream flow control window.
|
|
||||||
var sent int
|
var sent int
|
||||||
for sent <= initialWindowSize {
|
p := make([]byte, http2MaxFrameLen)
|
||||||
|
for sent < initialWindowSize {
|
||||||
<-conn.writableChan
|
<-conn.writableChan
|
||||||
if err := conn.framer.writeData(true, s.id, false, make([]byte, size)); err != nil {
|
n := initialWindowSize - sent
|
||||||
|
// The last message may be smaller than http2MaxFrameLen
|
||||||
|
if n <= http2MaxFrameLen {
|
||||||
|
if s.Method() == "foo.Connection" {
|
||||||
|
// Violate connection level flow control window of client but do not
|
||||||
|
// violate any stream level windows.
|
||||||
|
p = make([]byte, n)
|
||||||
|
} else {
|
||||||
|
// Violate stream level flow control window of client.
|
||||||
|
p = make([]byte, n+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +668,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 {
|
||||||
@ -671,7 +679,8 @@ func TestClientWithMisbehavedServer(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to open stream: %v", err)
|
t.Fatalf("Failed to open stream: %v", err)
|
||||||
}
|
}
|
||||||
if err := ct.Write(s, expectedRequest, &Options{Last: true, Delay: false}); err != nil {
|
d := make([]byte, 1)
|
||||||
|
if err := ct.Write(s, d, &Options{Last: true, Delay: false}); err != nil {
|
||||||
t.Fatalf("Failed to write: %v", err)
|
t.Fatalf("Failed to write: %v", err)
|
||||||
}
|
}
|
||||||
// Read without window update.
|
// Read without window update.
|
||||||
@ -693,18 +702,15 @@ func TestClientWithMisbehavedServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Test the logic for the violation of the connection flow control window size restriction.
|
// Test the logic for the violation of the connection flow control window size restriction.
|
||||||
//
|
//
|
||||||
// Generate enough streams to drain the connection window.
|
// Generate enough streams to drain the connection window. Make the server flood the traffic
|
||||||
callHdr = &CallHdr{
|
// to violate flow control window size of the connection.
|
||||||
Host: "localhost",
|
callHdr.Method = "foo.Connection"
|
||||||
Method: "foo.MaxFrame",
|
for i := 0; i < int(initialConnWindowSize/initialWindowSize+10); i++ {
|
||||||
}
|
|
||||||
// Make the server flood the traffic to violate flow control window size of the connection.
|
|
||||||
for {
|
|
||||||
s, err := ct.NewStream(context.Background(), callHdr)
|
s, err := ct.NewStream(context.Background(), callHdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err := ct.Write(s, expectedRequest, &Options{Last: true, Delay: false}); err != nil {
|
if err := ct.Write(s, d, &Options{Last: true, Delay: false}); err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -733,7 +739,7 @@ func TestEncodingRequiredStatus(t *testing.T) {
|
|||||||
Last: true,
|
Last: true,
|
||||||
Delay: false,
|
Delay: false,
|
||||||
}
|
}
|
||||||
if err := ct.Write(s, expectedRequest, &opts); err != nil || err == io.EOF {
|
if err := ct.Write(s, expectedRequest, &opts); err != nil && err != io.EOF {
|
||||||
t.Fatalf("Failed to write the request: %v", err)
|
t.Fatalf("Failed to write the request: %v", err)
|
||||||
}
|
}
|
||||||
p := make([]byte, http2MaxFrameLen)
|
p := make([]byte, http2MaxFrameLen)
|
||||||
|
Reference in New Issue
Block a user